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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:07:15+00:00 2026-05-29T06:07:15+00:00

I am trying to acquire single images from a camera, do some processing to

  • 0

I am trying to acquire single images from a camera, do some processing to them and release the used memory. I’ve been doing it for quite some time with a code similar to the one that follows:

char* img_data = new char[ len ]; // I retrieve len from the camera.

// Grab the actual image from the camera: 
// It fills the previous buffer with the image data.
// It gives width and height.

CvSize size;
size.width = width;
size.height = height;
IplImage* img = cvCreateImageHeader( size, 8, 1 );
img->imageData = img_data;

// Do the processing

cvReleaseImage( &img );

This code runs fine. I have recently read here (in the imageData description) that I shouldn’t be assigning data directly to img->imageData but use SetData() instead, like so:

cvSetData( img, img_data, width );

However, when I do it like this, I get a Segmentation fault at the cvReleaseImage() call.

What am I doing wrong?

Thank you.

EDIT: I have tried to compile and run the program that @karlphillip suggested and I DO get a segmentation fault using cvSetData but it runs fine when assigning the data directly.
I’m using Debian 6 and OpenCV 2.3.1.

  • 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-29T06:07:16+00:00Added an answer on May 29, 2026 at 6:07 am

    I had this problem as well, but believe it was fixed from what I gathered in
    this comment; namely to use cvReleaseImageHeader() and not cvReleaseImage().

    For example:

    unsigned int width = 100;
    unsigned int height = 100;
    unsigned int channels = 1;
    unsigned char* imageData = (unsigned char*)malloc(width*height*channels);
    // set up the image data
    
    IplImage *img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, channels);
    cvSetData(img, imageData, width*channels); 
    
    // use img
    
    cvReleaseImageHeader(&img);
    
    // free(imageData) when finished
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to acquire a thumbnail (of the first frame) from a video
I am trying to record data from my mobile phone's audio interface. I used
I'm trying to acquire the <gCal:color value=xxxxxx> value attribute from the Atom XML response
I'm trying to acquire a JSON which is being sent from an https secure
Trying to setup an SSH server on Windows Server 2003. What are some good
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
Trying to perform a single boolean NOT operation, it appears that under MS SQL
Trying to honor a feature request from our customers, I'd like that my application,
I'm trying to start visual studio 2010 from command prompt using 'RUNAS' so that
I am creating an image processing application in C# and trying to take advantage

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.