can I use CV, for video frame Perspective correction?

asked 2015-12-29 06:04:36 -0600

I am using both opencv and imagemagick to do perspective correction, for Usb video camera, and sort out the problems.

1.image magick only do perspective correction for 3 frames per second, but CV do around 15/sec . its good. 2. but quality wise IM is better than OCV after perspective correction. its bad. I am using the functions as follows lambda = cv::Mat::zeros(input.rows, input.cols, input.type() );

                inputQuad[0] = cv::Point2f(25,45);
                inputQuad[1] = cv::Point2f(440,45);
                inputQuad[2] = cv::Point2f(480,457);
                inputQuad[3] = cv::Point2f(0,457);  

                outputQuad[0] = cv::Point2f(0,0);
                outputQuad[1] = cv::Point2f(300,0);
                outputQuad[2] = cv::Point2f(300,400);
                outputQuad[3] = cv::Point2f(0,400);

                lambda = getPerspectiveTransform(inputQuad, outputQuad);
                output.rows=640;
                output.cols=480;
                warpPerspective(input,output,lambda,output.size());

if anything i did wrong guide me do to best.. thanks in advance

edit retag flag offensive close merge delete

Comments

1

You have to use 5 parameters to improve quality of warpPerspective

LBerger gravatar imageLBerger ( 2015-12-29 07:07:23 -0600 )edit

Can you upload a sample image to test ?

What do you mean by the quality is better with Image Magick ? Do you mean the resulting image is more "rectangular" with Image Magick or is less blurry for example ? What is the name of the command you use with Image Magick ?

Have you tried with findHomography instead of getPerspectiveTransform ?

Eduardo gravatar imageEduardo ( 2015-12-29 17:30:40 -0600 )edit

what is the 5th one? lberger

bharathiraja gravatar imagebharathiraja ( 2015-12-30 04:13:10 -0600 )edit

5th parameter defines how image is interpolated : cv::InterpolationFlags {

  cv::INTER_NEAREST = 0,
  cv::INTER_LINEAR = 1,
  cv::INTER_CUBIC = 2,
  cv::INTER_AREA = 3,
  cv::INTER_LANCZOS4 = 4,
  cv::INTER_MAX = 7,
  cv::WARP_FILL_OUTLIERS = 8,
  cv::WARP_INVERSE_MAP = 16
LBerger gravatar imageLBerger ( 2015-12-30 06:26:23 -0600 )edit