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 8429893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:27:43+00:00 2026-06-10T05:27:43+00:00

I found this code online .. and I wanted to try it > int

  • 0

I found this code online .. and I wanted to try it >

int main( int argc, char **argv )
{

VideoCapture cam1, cam2; //Middle and left cameras
//VideoCapture cam3; //Right camera

cam1.open(0);
cam2.open(1);
//cam3.open(2);

cam1.set(CV_CAP_PROP_FRAME_WIDTH, 320);
cam1.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

cam2.set(CV_CAP_PROP_FRAME_WIDTH, 320);
cam2.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

//cam3.set(CV_CAP_PROP_FRAME_WIDTH, 320);
//cam3.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
Mat frm1, frm2;

while(1)
{
    //Step 1: Get frames from a few cameras

    cam1 >> frm1; //Reference plane
    cam2 >> frm2; //Right-side target plane
    // cam3 >> frm3;

    if( frm1.empty()||frm2.empty() )
        break;


    //Step2: SURF detection
    int minHessian = 800;

    SurfFeatureDetector detector( minHessian );
    vector<KeyPoint> keypoints_1, keypoints_2;

    detector.detect( frm1, keypoints_1 );
    detector.detect( frm2, keypoints_2 );

    SurfDescriptorExtractor extractor; ///
    Mat descriptors_1, descriptors_2;
    extractor.compute( frm1, keypoints_1, descriptors_1 );
    extractor.compute( frm2, keypoints_2, descriptors_2 );


    //Step 3: Feature matching
    //-- Matching descriptor vectors with a matcher
    FlannBasedMatcher matcher;
    vector< DMatch > matches;
    matcher.match( descriptors_1, descriptors_2, matches);
    //vector< vector<DMatch> > matches;
    //matcher.knnMatch( descriptors_1, descriptors_2, matches,2);


    double max_dist = 0; double min_dist = 50;


    //-- Quick calculation of max and min distances between keypoints
    for( int i = 0; i < descriptors_1.rows; i++ )
    { double dist = matches[i].distance;
        if( dist < min_dist ) min_dist = dist;
        if( dist > max_dist ) max_dist = dist;
    }

    //printf("-- Max dist : %f \n", max_dist );
    //printf("-- Min dist : %f \n", min_dist );

    //-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
    vector< DMatch > good_matches;

    for( int i = 0; i < descriptors_1.rows; i++ )
    { if( matches[i].distance < 2*min_dist )
        { good_matches.push_back( matches[i]); }
    }

    Mat img_matches;
    drawMatches( frm1, keypoints_1, frm2, keypoints_2,
                good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
                vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );


    //-- Localize the object from frame1 in frame2
    vector<Point2f> frame1;
    vector<Point2f> frame2;

    for( int i = 0; i < good_matches.size(); i++ )
    {
        //-- Get the keypoints from the good matches
        frame1.push_back( keypoints_1[ good_matches[i].queryIdx ].pt );
        frame2.push_back( keypoints_2[ good_matches[i].trainIdx ].pt );
    }


    //Step 4: RANSAC and Homography

    Mat H = findHomography( Mat(frame2), Mat(frame1), CV_RANSAC, 5.0 );
    cout << "Homography for mapping the r-side plane to the ref. plane: " << endl << H << endl;
    //-- Show detected matches
    imshow("Matches", img_matches );

    //Step 5:Warping

    Mat result;
    warpPerspective(frm2,result,H,Size(3*frm1.cols,1.5*frm1.rows));
    imshow("Warping result",result);
    Mat half(result,Rect(0,0,frm2.cols,frm2.rows));
    frm1.copyTo(half);//Reference image

    //Step 6:Blending

    //Step 7:Showing the panoramic video

    imshow("Blended view",result);
    char c=waitKey(20);
    if (c==27)
        break;
}


return 0;
}

However, when I try to run the code, I found this error .. I checked the code in the OpenCV tutorial as well and they are almost exactly the same until the findhomography part.

OpenCV Error: Unsupported format or combination of formats
(type=0) in buildIndex_, file OpenCV-2.3.1/modules/flann/src/miniflann.cpp,
line 297 terminate called after throwing an instance of 'cv::Exception' what()
OpenCV-2.3.1/modules/flann/src/miniflann.cpp:297: error:
(-210) type=0 in function buildIndex_

Any ideas what could went wrong here ?

thank you

  • 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-10T05:27:44+00:00Added an answer on June 10, 2026 at 5:27 am

    my boss suggested restarting the computer, since I was using USB-cameras.. he said sometimes you need to restart it in some linux systems like Ubuntu for it to work again! and guess what? it really did work after restarting my computer!!!!!!!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this code online about the JavaCompiler JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); int result
i found this code -(NSString *) genRandStringLength: (int) len { NSMutableString *randomString = [NSMutableString
I found this code using Google. private int RandomNumber(int min, int max) { Random
I found this nice snippet of code online: rkApp = Registry.LocalMachine.OpenSubKey(SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run, true); Which runs
I found this code online and tweaked it a bit for my need to
I found this code online that has a procedure inside a procedure. I cannot
I found this code online: def merge(left, right): result = [] i ,j =
i found this code online and im trying to compile it, but gcc keeps
I found this code online for shuffling array elements, it works well, but I
I found this code online where the person is instantiating a class which has

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.