0

This is the 2nd time I face this problem. Previously, it was posted here and fixed. Last time, the attempt was made for Ubuntu Precise. I updated my system to the new Ubuntu LTS 14.04 and the problem occurs again and old fix doesn't seem to work

template <class NumType> void drawCircles(cv::Mat& image, const cv::Mat_<cv::Vec<NumType, 2> > points, cv::Scalar color) 
{   

            Point2d p0;

            for (int i = 0; i < points.cols; i++)   
            {       
                 p0.x = cvRound(points.at<cv::Vec<NumType, 2> >(0, i)[0]);      
                 p0.y = cvRound(points.at<cv::Vec<NumType, 2> >(0, i)[1]);

                 circle(image, p0, 5, color, 2, 8);     
            } 
}

I've tried to add template keyword from the hints discussed here. Specifically:

p0.x = cvRound(points.at<cv::template Vec<NumType, 2> >(0, i)[0]);

still no help The original error is:

error: expected primary-expression before ‘>’ token

by the way, this same code compiled cleanly in Windows with VS2008 or VS2010

Thank you!

Community
  • 1
  • 1
TSL_
  • 2,049
  • 3
  • 34
  • 55

1 Answers1

0

I had to create a simple example to test it. This does not do anything useful, but it proves that it compiles okay. You are 99% of the way there.

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

template <class NumType> 
void drawCircles(  cv::Mat& image, 
                   const cv::Mat_<cv::Vec<NumType, 2> > points, 
                   cv::Scalar color) 
{   

    // Added cv namespace
    cv::Point2d p0;

    for (int i = 0; i < points.cols; i++)   
    {
        // added template call to at rather than Vec
        p0.x = cvRound(points.template at<cv::Vec<NumType, 2> >(0, i)[0]);      
        p0.y = cvRound(points.template at<cv::Vec<NumType, 2> >(0, i)[1]);

        circle(image, p0, 5, color, 2, 8);     
    } 
}


int main(){

    cv::Mat image;
    cv::Mat_<cv::Vec2d> points;
    cv::Scalar color;


    drawCircles( image, points, color );

    return 0;
}
msmith81886
  • 2,286
  • 2
  • 20
  • 27
  • great! so the templated function is "at" not the Vec struct! Thank you! I can also compile it by now! – TSL_ Nov 04 '14 at 06:41