我已經成功在我的Raspberry Pi上安裝了OpenCV,並且一直在使用基本的C和C++代碼進行一些簡單的網絡攝像頭流式處理,實時Canny邊緣檢測等等。Raspberry Pi在運行OpenCV時變得無響應
但是,我遇到了我使用的兩個網絡攝像頭的問題。首先,我坐過的一款非常基礎且價格便宜的羅技,效果不錯,但圖像質量很不理想。但是當我切換到我的Logitech 510c相機時,圖像更好,但是Pi凍結。
相反,流式處理程序繼續運行良好,但我無法退出程序 - Raspberry Pi會停止響應鍵盤和鼠標,唯一的退出方法是拔掉Raspberry Pi。以下是一些代碼示例:
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
int main(){
int c, i, j;
//Capture frame from camera
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
if(!capture){
fprintf(stderr, "Error: capture is NULL \n");
getchar();
return -1;
}
//Set resolution of capture
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 256);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 192);
//Create window for display
cvNamedWindow("canny");
while(true){
//Find/mark edges using canny
IplImage* frame = cvQueryFrame(capture);
IplImage* grey = cvCreateImage(cvGetSize(frame), 8, 1);
cvCvtColor(frame, grey, CV_RGB2GRAY);
IplImage* frame2 = cvCreateImage(cvSize(grey->width+6, grey->height+6), grey->depth, grey->nChannels);
CvPoint offset = cvPoint(3,3);
cvCopyMakeBorder(grey, frame2, offset, IPL_BORDER_REPLICATE, cvScalarAll(0));
IplImage* edges = cvCreateImage(cvGetSize(frame2), IPL_DEPTH_8U, frame2->nChannels);
cvCanny(frame2, edges, 4900, 39200, 7);
cvShowImage("canny", edges);
//Wait for a keypress
int c = cvWaitKey(10);
if (c!=-1)
break;
} //End while
cvReleaseCapture (&capture);
cvDestroyWindow("canny");
return 0;
} //End main
我的代碼有問題嗎?我需要使用不同的攝像頭嗎?我超頻了Raspberry Pi;它可以簡單地處理與更好質量的相機流?
RPi有它自己的SE網站==> http://raspberrypi.stackexchange.com/ – Jason
謝謝,我不知道。我會在那邊問。我可以在這裏刪除它嗎? – crypto