0
我是opencv的新手。只是設法安裝並設置爲Visual 2013.我用我的筆記本電腦相機的實時流樣本對其進行了測試,結果正常。現在我想計算與網絡攝像頭之間的距離,將其顯示在屏幕中間的一個紅色激光點(live_stream)。告訴我我從哪裏開始?我知道我必須從屏幕中間找到R(紅色)像素,但我不知道如何做到這一點以及我可以使用哪些功能。請幫忙嗎? 從攝像頭的作品的實時流如下所示:用opencv計算到紅點的距離
#include "opencv2/highgui/highgui.hpp"
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <vector>
#include <stdio.h>
int main()
{
//Data Structure to store cam.
CvCapture* cap=cvCreateCameraCapture(0);
//Image variable to store frame
IplImage* frame;
//Window to show livefeed
cvNamedWindow("Imagine Live",CV_WINDOW_AUTOSIZE);
while(1)
{
//Load the next frame
frame=cvQueryFrame(cap);
//If frame is not loaded break from the loop
if(!frame)
printf("\nno");;
//Show the present frame
cvShowImage("Imagine Live",frame);
//Escape Sequence
char c=cvWaitKey(33);
//If the key pressed by user is Esc(ASCII is 27) then break out of the loop
if(c==27)
break;
}
//CleanUp
cvReleaseCapture(&cap);
cvDestroyAllWindows();
}
請不要使用棄用的C Api(IplImage,cvShowImage等),因爲您會遇到如此多的問題。 – GPPK
那我該用什麼? –
最好是opencv 3.0,但它在測試版中,所以使用2.4.10並使用C++ Api(CV :: mat,CV :: imshow)等 – GPPK