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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:56:13+00:00 2026-06-09T14:56:13+00:00

I am writing a program that uses OpenCV and involves intrinsic and distortion parameters.

  • 0

I am writing a program that uses OpenCV and involves intrinsic and distortion parameters. These parameters are loaded from .xml files saved on disc. I use the following commands in my opening declarations to load the files:

CvMat *intrinsic  = (CvMat*)cvLoad("Intrinsics.xml");
CvMat *distortion = (CvMat*)cvLoad("Distortion.xml");

This works fine as long as the files are in the program’s working directory. When they are not, the program crashes without any indication of the nature of the error. I have made the mistake of not having the xml files located correctly multiple times before, and I would like to make this easier to troubleshoot in the future.

I would like to create a guard against the files failing to load. Perhaps if they are not present my program could display an error message and exit gracefully. I saw the method suggested here, and it should work for me, but I was wondering if there was a cleaner way to do it without including another header.

For example, the OpenCV function cvQueryFrame returns 0 if it does not return a frame. I use the code

frame = cvQueryFrame(capture);
if(!frame)
{
    printf("ERROR: Could not get frame from webcam.");
    exit(-1);
}

to exit the program if cvQueryFrame fails to return a frame. I would like to do something similar with my matrix loading commands. Is this possible, and if so, how should I do it?

I checked the OpenCV documentation and could not find a description of cvLoad’s behaviour when it cannot find the file specified so I am not sure how to proceed.

I am writing this project in C++ and running it on Windows 7.

  • 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-09T14:56:14+00:00Added an answer on June 9, 2026 at 2:56 pm

    It works. Go ahead and try it yourself:

    CvMat *distortion = (CvMat*)cvLoad("Distortion.xml");
    if (!distortion)
    {
        printf("!!! cvLoad failed");
        exit(-1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Overview I am writing a Ruby program that uses data from mysql queries to
I am writing a program that uses prints a hex dump of its input.
I'm writing a program that uses regular expressions to make comparisons against the entire
I'm writing a python program that uses scons to build an .exe and then
I'm planning on writing a program for Linux that uses text to speech and
I'm writing a custom text-to-speech program that uses SAPI 5, and one problem I'm
I'm writing a program that for performance reasons uses shared memory (sockets and pipes
I'm writing an MPI program (Visual Studio 2k8 + MSMPI) that uses Boost::thread to
I'm writing a program that uses QUdpSocket for transmitting data over the network. This
I'm writing a program that uses the textbox in visual C# to read a

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.