Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8185409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:50:17+00:00 2026-06-07T01:50:17+00:00

Hi I have tried to modify the lkdemo.cpp in OpenCV/sample/cpp . I want to

  • 0

Hi I have tried to modify the lkdemo.cpp in OpenCV/sample/cpp.
I want to get perspective transform and then warpPerspective.
So I have added line (1) and (2) to do that.
Where declaration for image and output are as follows:

Mat gray, prevGray, image, output;

....

calcOpticalFlowPyrLK(prevGray, gray, points[0], points[1], status, err, winSize,
                                 3, termcrit, 0, 0.001);

 (1)   CvMat H = getPerspectiveTransform(points[0], points[1]); 
 (2)   cvWarpPerspective(&image, &output, &H,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, cvScalarAll(0));

...

Now when I try to see the output of warp image using imshow() I’m getting this error:

error: (-206) Unrecognized or unsupported array type in function cvGetMat

Backtrace after debugging is as follows:

(gdb) bt
#0  0xb7fdd424 in __kernel_vsyscall ()
#1  0xb77741ef in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0xb7777835 in __GI_abort () at abort.c:91
#3  0xb79e313d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#4  0xb79e0ed3 in ?? () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#5  0xb79e0f0f in std::terminate() () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#6  0xb79e105e in __cxa_throw () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#7  0xb7eb9363 in cv::error(cv::Exception const&) () from /usr/local/lib/libopencv_core.so.2.4
#8  0xb7e40496 in cvGetMat () from /usr/local/lib/libopencv_core.so.2.4
#9  0xb7ceb915 in cvImageWidgetSetImage(_CvImageWidget*, void const*) () from /usr/local/lib/libopencv_highgui.so.2.4
#10 0xb7ced4e0 in cvShowImage () from /usr/local/lib/libopencv_highgui.so.2.4
#11 0xb7cea378 in cv::imshow(std::string const&, cv::_InputArray const&) () from /usr/local/lib/libopencv_highgui.so.2.4
#12 0x0804a1ca in main (argc=2, argv=0xbffff724) at lkdemo-1.cpp:141
(gdb) 

Please anyone help me to fix this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:50:18+00:00Added an answer on June 7, 2026 at 1:50 am

    Actually I am getting above mentioned error due to mismatch in the number of points required for the getPerspectiveTransform method.
    Error was: error: OpenCV Error: Assertion failed (src.checkVector(2, CV_32F) == 4 && dst.checkVector(2, CV_32F) == 4) in getPerspectiveTransform

    Actually it requires four points for the transformation and I am using all points.
    Here is the correct way of calling getPerspectiveTransform with lk optical flow, in case you need.

        std::vector<Point2f> img1_corners(4);
    
        img1_corners[0] = cvPoint(0,0); 
        img1_corners[1] = cvPoint( gray.cols, 0 );
        img1_corners[2] = cvPoint( gray.cols, gray.rows ); 
        img1_corners[3] = cvPoint( 0, gray.rows );
    
        std::vector<Point2f> img2_corners(4);
    
        vector<uchar> status;
        vector<float> err;
        calcOpticalFlowPyrLK(gray, gray1, img1_corners, img2_corners, status, err, winSize,
                3, termcrit, 0, 0.001);
        //calcOpticalFlowPyrLK(gray, gray1, corner1, corner2, status, err, winSize,
        //      3, termcrit, 0, 0.001);
    
    
        Mat H = getPerspectiveTransform(img1_corners, img2_corners);
        //Mat H = getPerspectiveTransform(corner1, corner2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried so many different soloutions but cannot get this to work Here
So I have a sample application source I am trying to modify for my
I have tried desperately to modify the default charset for order confirmation emails to
Have tried to find solutions for this and can't really come up with anything.
I have tried to go through the jungle (really, PayPal, why don't you weed
I have tried searching over the internet about this problem but not able to
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I have tried many permutations but they all don't seems to work well. Am
I have tried a variety of different solutions found on stack and other places
I have tried everything in the book and EVERYTHING I could find on how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.