Ask Your Question
0

findCorners to Matrix

asked 2015-03-21 08:42:25 -0600

antithing gravatar image

updated 2015-03-21 08:53:20 -0600

Hi, I am attempting to use a solvePnp example that uses a chessboard, with points in place of the chessboard.

So I have this:

bool found = findChessboardCorners(gray, cbSize, imagePoints, CALIB_CB_FAST_CHECK);

which fills the imagepoints matrix that is initiated here:

vector< Point2d > imagePoints;

However, because i want to use non-chessboard points, i need to fill imagepoints with data from a cvGoodFeaturesToTrack operation.

So I find the markers, then i need to do something like...

for (int i = 0; i < corner_count; i++) {
//add to imagepoints matrix (corners[i].x, corners[i].y);
}

How would i go about doing this? Apologies if this is a stupid question, Matrix stuff is new to me!

many thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-03-21 08:57:54 -0600

Which version of OpenCV are you using? cvGoodFeaturesToTrack is old (deprecated, never use again, pure evil) C-Api. The new cv::GoodFeaturesToTrack just returns what you need:

cv::Mat img;
vector<cv::Point2f> corners;
cv::goodFeaturesToTrack(img,corners,100,1,1);
edit flag offensive delete link more

Comments

thank you! When i replace my feature tracking section with that, it runs. But if i try to print the corner data, or use it in the solvePnp, it gives me a 'vector subscript out of range error. also, i had a for (int i = 0; i < corner_count; i++) { //do stuff } section, what would i replace corner_count with? My old code, for clarification...

const int MAX_CORNERS = 100; CvPoint2D32f corners[MAX_CORNERS] = { 0 }; int corner_count = MAX_CORNERS; double quality_level = 0.1; double min_distance = 5; int eig_block_size = 3; int use_harris = false;

        cvGoodFeaturesToTrack(gray_frame,
            eig_image,                    // output
            temp_image,
            corners,
            &corner_count,
            quality_level,
            min_distance,
            NULL,
            eig_block_size,
            use_harris);
antithing gravatar imageantithing ( 2015-03-21 09:27:13 -0600 )edit

ah sorry, i think i am an idiot. So i would replace Mat::img with my actual image, right? it is currently an:

IplImage* gray_frame = 0;

should i convert that?

thanks again!

antithing gravatar imageantithing ( 2015-03-21 09:30:48 -0600 )edit

ok, it's working! Thanks for the help :)

antithing gravatar imageantithing ( 2015-03-21 12:34:07 -0600 )edit

"IplImage* gray_frame " Why are you using this old OpenCV Version?

FooBar gravatar imageFooBar ( 2015-03-23 02:41:32 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-21 08:42:25 -0600

Seen: 384 times

Last updated: Mar 21 '15