OpenCV, use estimateRigidTransform to transform a contour -
ok here's scenario. built paper detection app finds piece of paper in image. doesn't work 100% of time, given white balance , focusing changes, if found sheet of paper in frame 1, want show border around in frame 2 (in reality there can many frame gap), if didn't find in frame 2. in order so, keep old image, , old 4 point contour frame 1.
then, in frame n did not find convex contour, want transform old contour using affine transformation compute using estimagerigidtransform.
i 100% positive math off, i'm not sure where:
// new image = 3200 x 6400 // old image = 3200 x 6400 // old contour = contour found in old image, same scale vector<cv::point> transformcontourwithnewimage(mat & newimage, mat & oldimage, vector<cv::point> oldcontour) { cgfloat ratio = newimage.size().height / 500.0; cv::size outputsize = cv::size(newimage.size().width / ratio, 500); mat image_copy; resize(newimage, image_copy, outputsize); //shrink images down computations cheaper mat oldimage_copy = cv::mat(); resize(oldimage, oldimage_copy, outputsize); cv::mat transform = estimaterigidtransform(image_copy, oldimage_copy, false); vector<cv::point> transformedpoints; cv::transform(oldcontour, transformedpoints, transform); return transformedpoints; } i think need scale transform, since done on smaller image contour vector represents. crash saying transform mat has wrong number of rows/cols
Comments
Post a Comment