如何在opencv中获取被跟踪对象的坐标(x,y值) 我试图用C++中的开放式CV跟踪瞳孔虹膜。 我要追踪瞳孔虹膜的坐标。我怎样才能得到它? 现在我可以跟踪瞳孔虹膜,但我想用数字输出坐标。哪种功能可以实现这一点
到目前为止,我编写的代码如下:如何在opencv中获取被跟踪对象的坐标(x,y值) 我试图用C++中的开放式CV跟踪瞳孔虹膜。 我要追踪瞳孔虹膜的坐标。我怎样才能得到它? 现在我可以跟踪瞳孔虹膜,但我想用数字输出坐标。哪种功能可以实现这一点,c++,opencv,C++,Opencv,到目前为止,我编写的代码如下: #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/core/core.hpp" #include "opencv2/opencv.hpp" #include <iostream> #include <stdio.h> using namespace cv; using namespace std;
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;
int main() {
VideoCapture cap(1); // open the default camera
cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 360);
if(!cap.isOpened()) // check if we succeeded
return -1;
namedWindow("Video",1);
Mat src_gray;
while(1) {
Mat frame,grey,edge,draw,src_gray;
cap >> frame;
cvtColor( frame, grey, CV_BGR2GRAY ); // get a new frame from camera
Canny( grey, edge, 50, 150, 3);
edge.convertTo(draw, CV_8U);
GaussianBlur( edge, src_gray, Size(9, 9), 2, 2 );
vector<Vec3f> circles;
HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT, 2, src_gray.rows/16, 80, 100, 30, 50 );
/// Draw the circles detected
for( size_t i = 0; i < circles.size(); i++ ) {
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
int radius = cvRound(circles[i][2]);
// circle center
circle( src_gray, center, 3, Scalar(0,255,0), -1, 8, 0 );
// circle outline
circle( src_gray, center, radius, Scalar(0,0,255), 3, 8, 0 );
}
Rect Rec(370,100,200,150);
rectangle(src_gray,Rec,Scalar(255),1,8,0);
namedWindow("roi",640*360);
Mat Roi=src_gray(Rec);
imshow("roi",Roi);
imshow("Video", src_gray);
// Press 'c' to escape
if(waitKey(30) == 'c') break;
}
return 0;
}
#包括“opencv2/highgui/highgui.hpp”
#包括“opencv2/imgproc/imgproc.hpp”
#包括“opencv2/core/core.hpp”
#包括“opencv2/opencv.hpp”
#包括
#包括
使用名称空间cv;
使用名称空间std;
int main(){
VideoCapture(1);//打开默认摄像机
封盖套件(CV、封盖、支架、宽度640);
封盖套件(CV、封盖、支柱、框架、高度,360);
if(!cap.isopend())//检查我们是否成功
返回-1;
namedWindow(“视频”,1);
Mat src_gray;
而(1){
灰色、边缘、拉伸、src_灰色垫架;
cap>>框架;
cvtColor(帧,灰色,CV_BGR2GRAY);//从相机获取新帧
坎尼(灰色,边缘,50,150,3);
边缘转换(绘图,CV_8U);
高斯模糊(边缘,src_灰,大小(9,9),2,2);
矢量圆;
HOUGH圆(src_gray,圆,CV_HOUGH_渐变,2,src_gray.rows/16,80,100,30,50);
///画出检测到的圆
对于(size_t i=0;i
你的中心
变量不是在圆圈中
循环你要寻找的坐标吗?是的…你说得对..谢谢:)