본문 바로가기
카테고리 없음

오렌지파이 카메라 연결 오류 해결 방법 - [video4linux2,v4l2 @ 0x10940a0] Not a video capture device./dev/video0: No such device

by newbeverse 2024. 3. 7.

이 포스팅은 ....

 오렌지 파이에서 OpenCV를 활용한 프로젝트를 하기 위해서는 카메라를 사용하는 것이 필수적인 과정입니다.  이러한 기초과정에서 흔히 발생하는 카메라 연결 오류를 소개하고 이를 해결 하기위한 과정을 담은 포스팅입니다.

 

OpenCV 관련 예제 코드 (해결 전)

핵심 포인트는

cap = cv2.VideoCapture(0) 인 코드를

cap = cv2.VideoCapture("/dev/video1") 로 변경하면서 해결됐다는 점입니다.

import cv2

# Open the default camera (index 0)
cap = cv2.VideoCapture("/dev/video1")

# Check if the camera is opened successfully
if not cap.isOpened():
    print("Error: Could not open camera.")
    exit()

# Loop to continuously capture frames from the camera
while True:
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Check if the frame is read correctly
    if not ret:
        print("Error: Failed to capture frame.")
        break

    # Display the frame
    cv2.imshow('Camera Feed', frame)

    # Wait for 'q' key to exit the loop
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# Release the camera and close OpenCV windows
cap.release()
cv2.destroyAllWindows()

 

결과

 

기타 : 에러 메세지

root@orangepilite:~/test# python3 test.py
[ WARN:0] global ./modules/videoio/src/cap_gstreamer.cpp (2075) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Device '/dev/video0' is not a capture device.
[ WARN:0] global ./modules/videoio/src/cap_gstreamer.cpp (1053) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global ./modules/videoio/src/cap_gstreamer.cpp (616) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ WARN:0] global ./modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video0): can't open camera by index
Error: Could not open camera.

반응형