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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:57:32+00:00 2026-05-19T02:57:32+00:00

I’m passing an array of images (IplImage**) to an object in C++ using OpenCV.

  • 0

I’m passing an array of images (IplImage**) to an object in C++ using OpenCV. I’m then trying to iterate over that array and resize them all to a fixed size (150×150)

I’m doing it this way:

for(int i = 0; i< this->numTrainingFaces; i++)
{
    IplImage* frame_copy = cvCreateImage( cvSize(150,150), this->faceImageArray[0]->depth, this->faceImageArray[0]->nChannels );
    cout << "Created image" << endl;
    cvResize(this->faceImageArray[i], frame_copy);
    cout << "Resized image" << endl;
    IplImage* grey_image = cvCreateImage( cvSize( frame_copy->width, frame_copy->height ), IPL_DEPTH_8U, 1 );
    cout << "Created grey image" << endl;
    cvCvtColor( frame_copy, grey_image, CV_RGB2GRAY );
    cout << "Converted image" << endl;
    this->faceImageArray[i] = grey_image;
    cvReleaseImage(&frame_copy);
    cvReleaseImage(&grey_image);
}

But I’m getting this output, and I’m not sure why:

Created image
Resized image
Created grey image
Converted image
Created image
OpenCV Error: Assertion failed (src.type() == dst.type()) in cvResize, file /build/buildd/opencv-2.1.0/src/cv/cvimgwarp.cpp, line 3102
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.1.0/src/cv/cvimgwarp.cpp:3102: error: (-215) src.type() == dst.type() in function cvResize

Aborted

I’m basically just trying to replace the image in the array with the resized one in as few steps as possible.

Edit:

Revised my code as follows:

for(int i = 0; i< this->numTrainingFaces; i++)
{

    IplImage* frame_copy = cvCreateImage( cvSize(150,150), this->faceImageArray[i]->depth, this->faceImageArray[i]->nChannels );
    cvResize(this->faceImageArray[i], frame_copy);
    IplImage* grey_image = cvCreateImage( cvSize( frame_copy->width, frame_copy->height ), IPL_DEPTH_8U, 1 );
    cvCvtColor( frame_copy, grey_image, CV_RGB2GRAY );
    faceImageArray[i] = cvCreateImage( cvSize(grey_image->width, grey_image->height), grey_image->depth, grey_image->nChannels);
    cvCopy(grey_image,faceImageArray[i]);

    cvReleaseImage(&frame_copy);
    cvReleaseImage(&grey_image);
}

Then later on I’m performing some PCA, and get this output:

OpenCV Error: Null pointer (Null pointer to the written object) in cvWrite, file /build/buildd/opencv-2.1.0/src/cxcore/cxpersistence.cpp, line 4740

But I don’t think my code has got to the point where I’m explicitly calling cvWrite, so it must be part of the library. I can give a full implementation if necessary – is there anything in my code that’s going to create a null pointer?

My full source code is here: http://pastie.org/1447022 – a class is created, variables are set, then learn() is called.

  • 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-19T02:57:33+00:00Added an answer on May 19, 2026 at 2:57 am
    • Why do you use the C interface when you’re using C++? The C++ interface is far friendlier and you wouldn’t have had this problem with it.
    • Your error is simple – your image differ in type, so you can’t use the type from the first image for all images.

    The line

    IplImage* frame_copy = cvCreateImage( cvSize(150,150), this->faceImageArray[0]->depth, this->faceImageArray[0]->nChannels );
    

    should be

    IplImage* frame_copy = cvCreateImage( cvSize(150,150), this->faceImageArray[i]->depth, this->faceImageArray[i]->nChannels );
    

    Also, this-> is usually a no-op. faceImageArray[0]->depth, faceImageArray[0]->nChannels should suffice.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.