我尝试在Ubuntu中使用OpenCV 3.1来连接Webcam。 我的计划如下。
void main(){
VideoCapture camera(0);
Mat frame;
while(true){
camera >> frame;
imshow("test", frame);
int key = waitKey(10);
if(key == 27){
break;
}
}
return 0;
}
错误是
GStreamer Plugin: Embedded video playback halted; module v4l2src0 reported: Devi
ce '/dev/video0' cannot capture at 1280x720
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nn/Softwares/opencv/opencv/modules
/videoio/src/cap_gstreamer.cpp, line 818
terminate called after throwing an instance of 'cv::Exception'
what(): /home/nn/Softwares/opencv/opencv/modules/videoio/src/cap_gstreamer.
cpp:818: error: (-2) GStreamer: unable to start pipeline
in function cvCaptureFromCAM_GStreamer
答案 0 :(得分:0)
这是一个使用OpenCV 4+的golang存储库,它可以在Ubuntu 19.10和golang 1.13.4上运行网络摄像头和其他opencv玩具
// https://github.com/hybridgroup/gocv
package main
import (
"gocv.io/x/gocv"
)
func main() {
webcam, _ := gocv.OpenVideoCapture(0)
window := gocv.NewWindow("Hello")
img := gocv.NewMat()
for {
webcam.Read(&img)
window.IMShow(img)
window.WaitKey(1)
}
}