私は、最新のJetpack(TegraはR23.2用のLinux)と私のJETSON TX1を点滅し、次のコマンドは完璧に動作します:Jetson TX1組み込みカメラから画像を受信する方法は?
gst-launch-1.0 nvcamerasrc fpsRange="30.0 30.0" ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! nvtee ! nvvidconv flip-method=2 ! 'video/x-raw(memory:NVMM), format=(string)I420' ! nvoverlaysink -e
私はウェブカメラから画像を受信するには、以下のPythonプログラムを使用しようとしました:
ソース:
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /hdd/buildbot/slave_jetson_tx_2/35-O4T-L4T-Jetson-L/opencv/modules/imgproc/src/color.cpp, line 3739
Traceback (most recent call last):
File "webcam.py", line 11, in <module>
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: /hdd/buildbot/slave_jetson_tx_2/35-O4T-L4T-Jetson-L/opencv/modules/imgproc/src/color.cpp:3739: error: (-215) scn == 3 || scn == 4 in function cvtColor
:
http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
私は、次のエラーを得ました
私はウェブカメラから画像を受け取ることができないということを知っています。私もwebcamから受信した画像を表示するようにコードを変更しましたが、それは私にはカメラから取得する画像がないことを意味するエラーが表示されます。
私も次のコードでC++を使用しようとしました:
#include "opencv2/opencv.hpp"
using namespace cv;
int main(int argc, char** argv)
{
VideoCapture cap;
// open the default camera, use something different from 0 otherwise;
// Check VideoCapture documentation.
if(!cap.open(0))
return 0;
for(;;)
{
Mat frame;
cap >> frame;
if(frame.empty()) break; // end of video stream
imshow("this is you, smile! :)", frame);
if(waitKey(1) == 27) break; // stop capturing by pressing ESC
}
// the camera will be closed automatically upon exit
// cap.close();
return 0;
}
、それは
g++ webcam.cpp -o webcam `pkg-config --cflags --libs opencv`
を使用してエラーなしでコンパイルされた。しかし、私はプログラムを実行しているとき、再び、私はこのエラーを受け取ります:
$ ./webcam
Unable to stop the stream.: Device or resource busy
Unable to stop the stream.: Bad file descriptor
VIDIOC_STREAMON: Bad file descriptor
Unable to stop the stream.: Bad file descriptor
何が欠けていますか?このプログラムを実行する前にウェブカメラを起動するコマンドがありますか?
この問題を解決しましたか? – Qazi
ここで同じ問題が発生した場合は、解決策を見つけたらお知らせください。 – SimpleMan