【问题标题】:How to get x and y cordinates separately to int from cvPoint?如何从cvPoint分别获取x和y坐标到int?
【发布时间】:2017-04-20 02:56:56
【问题描述】:

在下面的程序中,我需要从 cvPoint 值中找到坐标的 x 和 y 值。

for(int i=0; i<nomdef; i++)  
{
    if(defectArray[i].depth > 40 )
    {
        con=con+1;

        cvLine(src, *(defectArray[i].start), *(defectArray[i].depth_point),CV_RGB(255,255,0),1, CV_AA, 0 );  
        cvCircle(src, *(defectArray[i].depth_point), 5, CV_RGB(0,0,255), 2, 8,0);  
        cvCircle(src, *(defectArray[i].start), 5, CV_RGB(0,255,0), 2, 8,0);  
        cvLine(src, *(defectArray[i].depth_point), *(defectArray[i].end),CV_RGB(0,255,255),1, CV_AA, 0 );  
        cvDrawContours(src,defects,CV_RGB(0,0,0),CV_RGB(255,0,0),-1,CV_FILLED,8);
    }
} 

圆是使用点绘制的。我需要从这些点获取 x 和 y 坐标。缺陷数组由CvConvexityDefect* defectArray创建。

【问题讨论】:

    标签: c++ linux opencv gesture-recognition


    【解决方案1】:

    如果你的点对象的名称是 myPoint ,那么你可以访问它的 x 和 y 值

    int x = myPoint.x ;
    int y = myPoint.y ;
    

    在你的情况下,你可以写

    int x = *(defectArray[i].start).x ; 
    int y = *(defectArray[i].start).y ;
    

    【讨论】:

    • 请求'(defectArray + 32u)->CvConvexityDefect::start'中的成员'x',它是指针类型'CvPoint*'(也许你打算使用'->'?) int x1 = *(defectArray[1].start).x;我有关于它的错误.. 我该怎么办?
    猜你喜欢
    • 1970-01-01
    • 2022-11-13
    • 1970-01-01
    • 2018-05-29
    • 2012-09-17
    • 1970-01-01
    • 2014-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多