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

  • Home
  • SEARCH
  • 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 7075849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:13:37+00:00 2026-05-28T06:13:37+00:00

I spend the whole morning today searching for a way to save an array

  • 0

I spend the whole morning today searching for a way to save an array of images in IplImage type in openCV and failed.

This is what I am trying to do :

IplImage* GetThresholdedImage(IplImage* img) {

IplImage* imageTest[2];

IplImage* imgHSV = cvCreateImage(cvGetSize(img), 8, 3); // hold the resulted HSV image

cvCvtColor(img, imgHSV, CV_BGR2HSV); // convert the coming image from the camera from RGB format to HSV (Hue, Saturation, Value)

imageTest[0] = cvCreateImage(cvGetSize(img), 8, 1); //hold the thresholded image of the yellow color

imageTest[1] = cvCreateImage(cvGetSize(img), 8, 1); //hold the thresholded image of the red color

cvSmooth(imgHSV, imgHSV, CV_GAUSSIAN, 11, 11); //smooth the image to remove the noise from the image

cvInRangeS(imgHSV, cvScalar(24, 100, 150), cvScalar(34, 255, 255),
        imageTest[0]); //this function filter out the colors in this range (This is a yellow color)

cvInRangeS(imgHSV, cvScalar(172, 100, 150), cvScalar(179, 255, 255),
        imageTest[1]); //this function filter out the colors in this range (This is a red color)


cvReleaseImage(&imgHSV);

return *imageTest;

}

Now when I try to return the array in the main in order to process it –>

IplImage *thresholdedImage;// = cvCreateImage(cvGetSize(frame), 8, 1); // to store the thresholded image

IplImage *yellow = cvCreateImage(cvGetSize(frame), 8, 1);
IplImage *red = cvCreateImage(cvGetSize(frame), 8, 1);


//===========================================

// start creating three windows to show the video after being thresholded, after it passes the contour function and the final video

cvNamedWindow("display", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Threshold", CV_WINDOW_AUTOSIZE);
cvNamedWindow("contoured", CV_WINDOW_AUTOSIZE);

while (key != 'q') { // grab the video unless the user press q button

    frame = cvQueryFrame(capture);

    if (!frame) {
        break;
    }

    //start the actual video processing on real-time frames

    //first output of the threshold method
    thresholdedImage = GetThresholdedImage(frame);

    yellow = *thresholdedImage;

    red = *thresholdedImage++;

    //insert the resulted frame from the above function into the find contour function
    cvFindContours(yellow, storage, &contours, sizeof(CvContour),
            CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));

    cvFindContours(red, storage, &contours, sizeof(CvContour),
            CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));

however it gives me error !!!

any help is appreciated , 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-05-28T06:13:38+00:00Added an answer on May 28, 2026 at 6:13 am

    An array of pointers to IplImage would be IplImage**. Also note, that you have to provide the buffer from the outside, as you can’t return a pointer to local (non-static) data.

    void GetImages(IplImage** images, unsigned int num) {
        // assign pointers here
        images[0] = ...
        images[1] = ...
    }
    
    IplImage *images[2];
    GetImage(images, 2);
    

    As an alternative, you could as well create the array within your function using new or malloc and return the pointer to it. Just ensure you delete/free it later on.

    IplImage **CreateImages(unsigned int num) {
        IplImage **images = new IplImage*[num];
        // assign again
        images[0] = ...
        return images;
    }
    

    Also ensure you free the images, once you’re done with them. So you shouldn’t use the approach you used above (increasing the pointer). Instead simply use array syntax to access n-th element.

    Your code fails due to returning only a single pointer to the first image instead of the actual array.

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

Sidebar

Related Questions

I've spend the whole morning on this and I am absolutely stumped. I have
I've spent the whole morning on gSkinner trying to change this regex. It correctly
This morning, while trying to migrate some files from my test server to my
I spend almost whole day trying to render simple polygon using opengl 1.1 and
Spent my whole morning trying to find where my return value was getting garbled.
I spent the whole of last night searching for a free AspNet web chat
I've spent a whole day on this already without figuring it out. I'm hoping
I have spent the whole day trying to make a script which on submit
HI, I've been trying to work my way thru the SICP book, I found
I don't spend a whole lot of time in MySQL, but I have been

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.