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