0

I am working on traffic sign detection project. Circular traffic sign has been detected, now i want to calculate optical flow vector to traffic sign only but not whole image. I could find radius of detected circle but not sure how to use this to create a circular mask IplImage to provide to "cvGoodFeatureToTrack" and "cvCalcOpticalFlowPyrLK()"

Any suggestion please ?

user3042916
  • 87
  • 3
  • 12
  • 3
    please **do not** use IplImage* or any of the deprecated cv* functions, but the c++ api (cv::Mat, etc.) – berak Jan 28 '16 at 11:10
  • I agree but project is developed in deprecated cv* function since beginning. So not possible to switch now... – user3042916 Jan 28 '16 at 11:13

1 Answers1

1

Say you have the center and radius of the traffic sign, i.e.:

cv::Point center(200, 300);
int radius = 50;

The region of interest, where goodFeaturesToTrack will work can be controled by a CV_8UC1 mask which has the same size as the input image:

cv::Mat mask = cv::Mat::zeros(grayFrame.size(), CV_8UC1);
cv::circle(mask, center, radius, cv::Scalar::all(255), -1);

Finally call the function with our new mask filled with 255s according to the traffic sign:

cv::goodFeaturesToTrack(grayFrame, corners, 100, 0.01, 10, mask);
Kornel
  • 5,264
  • 2
  • 21
  • 28