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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:30:59+00:00 2026-05-27T05:30:59+00:00

I am trying to get camera calibration parameters by using opencv camera calibration functions.

  • 0

I am trying to get camera calibration parameters by using opencv camera calibration functions. I have a video and trying to find the calibration parameters and find the points in the video which inclused a checkboard in different psoitions. But i couldnt passed the calibration phase yet. I can find the corner of the checkboard and show them in openCV window but when it comes to line:

calibrateCamera(objectPoints,imagePoints..............) 

it throws exception and stops.

I get the following error: OpenCV error: Assertion failed 0 &&nimages==int imagePoints1.total ()&&

Here is my code:

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "C:/opencv/include/opencv/cv.h"

#include <iostream>
#include <math.h>

using namespace cv;
using namespace std;

std::vector<cv::Point2f> imageCorners;
std::vector<cv::Point3f> objectCorners;
std::vector<std::vector<cv::Point3f>> objectPoints;
std::vector<std::vector<cv::Point2f>> imagePoints;

void addPoints(const std::vector<cv::Point2f>&imageCorners, const std::vector<cv::Point3f>& objectCorners)
{
// 2D image points from one view
imagePoints.push_back(imageCorners);
// corresponding 3D scene points
objectPoints.push_back(objectCorners);
}
int main()
{

int key;
cv::Mat   image;
cv::Mat   gray_image;

VideoCapture cap("here goes path of the file"); 
   if (!cap.isOpened())  // check if we succeeded
       cout<<"failed";
else
   cout<<"success";

    cvNamedWindow( "video",0);

cv::Size boardSize(8,6);
// output Matrices
cv::Mat cameraMatrix;
std::vector<cv::Mat> rvecs, tvecs;
cv::Mat distCoeffs;

for (int i=0; i<boardSize.height; i++) 
{
    for (int j=0; j<boardSize.width; j++) 
    {
        objectCorners.push_back(cv::Point3f(i, j, 0.0f));
    }
}
int frame=1;
int corner_count=0;
while(1) 
{
    if(cap.read(image))
    {
        frame++;
        if(frame%20==0)
        {
            if(waitKey(30) >= 0) break;

            bool found = cv::findChessboardCorners(image, boardSize, imageCorners);

            cvtColor( image, gray_image, CV_RGB2GRAY );


                addPoints(imageCorners, objectCorners);

            //bool found = cv::findChessboardCorners(image,boardSize, imageCorners);
            cv::drawChessboardCorners(gray_image,boardSize, imageCorners,found);
            imshow( "video",  gray_image );
        }
    }
    else
        break;

}
int flag=0;
std::string text="";

for (int i=1; i<imagePoints.size();i++)
{
    std::stringstream out;
    out << imagePoints[i];
    text=out.str();
    cout<<text<<endl;

}

calibrateCamera(objectPoints,imagePoints,gray_image.size(), cameraMatrix, distCoeffs, rvecs, tvecs, flag);

return 0;

}
  • 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-05-27T05:31:00+00:00Added an answer on May 27, 2026 at 5:31 am

    Print the size of all your std::vector, I suspect you are passing an empty vector to that function.

    EDIT:

    I’ve shared some instructions in this answer on how to do camera calibration. Those references include working source code. You’ll probably have to do a small adaptation on those programs so they work with video instead.

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

Sidebar

Related Questions

Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
I'm new here. I have been trying to create a video capture app using
I am trying to capture video from a camera. i have gotten the captureOutput:didOutputSampleBuffer:
Here's the problem. I am using AVCaptureVideoDataOutput to get video frames from camera and
I am trying to create bitmap class using bitmapfactory. I get camera preview image
I'm trying to implement a stereo camera calibration app using emgu cv. My problem
I am trying to get the duration of a video taken with the camera
I've got a Sony network camera (SNC-RZ25N) that I am trying desperately to get
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get my css / C# functions to look like this: body {

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.