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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:00:20+00:00 2026-06-07T05:00:20+00:00

This is how we display and process an Image using Opencv: int _tmain(int argc,

  • 0

This is how we display and process an Image using Opencv:

int _tmain(int argc, _TCHAR* argv[]) {
    IplImage* img = cvLoadImage( "MGC.jpg" );
    cvThreshold( img, img,  200, 255, CV_THRESH_BINARY );
    cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    cvShowImage("Example1", img);
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow( "Example1" );
    return 0;
}

Now can you help me to achieve my goal as outlined below:

int _tmain(int argc, _TCHAR* argv[]) {
    Some code here (using some API other than OpenCv).... // Captures a frame and  
    //streams the data into a buffer Buf
    Buffer B= Buf; // B contain binary image data i.e 16 bit pixel values
    cvThreshold( B, B,  200, 255, CV_THRESH_BINARY );//Notice I am putting B and not an 
                                                     //Image(legal?)
    cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    cvShowImage("Example1", B); //Notice I am putting B and not an Image(legal?)   
    cvWaitKey(0);
    cvReleaseImage( &B );
    cvDestroyWindow( "Example1" );
    return 0;
}

Notice that I have not used any hard-disk read/write operation in the second code snippet, such as the following:

  IplImage* img = cvLoadImage( "MGC.jpg" );

Basically I am working with real-time scenario thus I am bypassing the time consuming cvLoadImage. Obviously not saving the data into hard-disk, my entire data is still in the Buffer B. This save my time which is critical for my application.

Note: The fact is I will be doing more processing on the Buffer B, such as applying cvminmaxloc etc. But all these functions require an Image loaded from disk, not a buffer such in my case.

Can some point me to right direction to achieve my goal of working on Buffers instead of Images stored in the hard-disk? Am I committing some mistake in understanding the openCV functions?

Update:

A suggested below I can use imdecode for reading images from buffer. As explained above actually I will be doing processing on the image using OpenCv functions, for example CVMinMaxLoc and

 cvThreshold( src, src,  200, 255, CV_THRESH_BINARY );   

Now can I put Buffer as the first argument instead of Image in cvThreshold( )? If not then what is the alternative to dealing with Buffers (containing pixel values) with openCv functions? If there is no direct method to work with buffers, then what is the indirect method to achieve this goal? What is the work around?

In short I do not want to bring the data to hard disk before doing any processing.

  • 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-07T05:00:22+00:00Added an answer on June 7, 2026 at 5:00 am

    Understand that most of the C interface of OpenCV deals with IplImage, not Buffer nor any other custom data type. In other words, doing:

    Buffer B = Buf; 
    cvThreshold( B, B,  200, 255, CV_THRESH_BINARY );
    

    will issue a compiling error because cvThreshold() requires the data to be encapsulated in an IplImage.

    I don’t want to run the risk of being Captain Obvious, but you need to convert Buffer to IplImage. So how do you do that, one might ask. Well, IplImage is simple data type that holds these important pieces of information together:

    • The size of the image (width/height);
    • The bit depth of the image;
    • The number of channels;
    • And the data (pixels) of the image;

    And how do you create a IplImage from scratch? Call cvCreateImageHeader() followed by cvSetData().

    Note: for the depth parameter, you might want to use either IPL_DEPTH_16U or IPL_DEPTH_16S. If your image is RGB, the number of channels is 3. After you are done using the IplImage, don’t forget to call cvReleaseImage() to free it’s resources.

    I believe the real challenge is: how will you extract all these information from Buffer. Good luck!

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

Sidebar

Related Questions

I am using this code to display image from URL, but it is not
I'm using the Image control to display an 8-bit grayscale image that I process
I got this Base64 gif image: R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7 Now I want to display this
I am using some CoreImage filters to process an image. Applying the filter to
I want to do something like this: [Display(Name = Plain text. <span class=\red strong\>Red
here is ma rss code, this display description in Arabic but in title it
In my XAML file I want to display this text which contains double and
Any suggestions on the best way to display this table on an Android platform?
Hey I am getting this confirmation by firefox. To display this page, Firefox must
I have the following number: 4.3 I'd like to display this number as 4,3

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.