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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:02:45+00:00 2026-06-03T07:02:45+00:00

I receive images on the PC from two cameras. The stream is not continuous

  • 0

I receive images on the PC from two cameras. The stream is not continuous but takes place at event detection. Therefore, I have to receive around 8-10 image pairs after a particular time. Since I have to process the images, I want to first keep all the images in a large buffer and later process them in a batch. It is also acceptable to keep images in two large buffers (one for each camera). How do I keep these pair of images in one (or two) large buffer(s)? I am implementing this program in C.

  • 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-03T07:02:47+00:00Added an answer on June 3, 2026 at 7:02 am

    Assumeing the following API to get the image:

    int ImageGet(
      char * pBuffer, 
      size_t * pSize); /* returns 0 on success or any other value if no image is available or on error */
    

    you could do the following:

    #include <stdlib.h>
    #include <string.h>
    
    ...
    
    #define IMAGESIZE_MAX (1024*1024) 
    
    char * pBuffer = NULL;
    char * pBufferCurrent = pBuffer;
    int iResult = 0;
    size_t size = IMAGESIZE_MAX;
    size_t sizeTotal = 0;
    
    do 
    {
      char * pBufferCurrent = realloc (
        pBuffer, 
        sizeTotal + sizeof(size) + size);
    
      if (!pBufferCurrent)
      {
        break;
      }
    
      pBuffer = pBufferCurrent;
    
      pBufferCurrent += sizeTotal;
    
      if ((iResult = ImageGet (
        pBufferCurrent + sizeof(size), 
        &size))
      {
        break; 
      }
    
      memcpy (
        pBufferCurrent,
        &size, 
        sizeof(size));
    
      sizeTotal += (sizeof(size) + size);
    } while (1);
    
    ...
    

    This stores your data sequentially:

    [     size 1     ][  image data 1  ][     size 2     ][  image data 2  ]...
    <-sizeof(size_t)-><-    size 1    -><-sizeof(size_t)-><-    size 2    ->
    

    in the buffer pointed to by pBuffer.


    To retrieve a reference to the data describing image N from the buffer pBuffer you could use the following method:

    const char * BufferImageGetByIndex(
        const char * pBuffer,
        unsigned indexImage)
    {
      for (unsigned indexImageCnt = 0;
        indexImageCnt < indexImage;
        ++ indexImageCnt)
      {
        pBuffer += sizeof(size_t) + *((size_t *) pBuffer);
      }
    
      return pBuffer;
    }
    

    Then to actually get an image you could do like so:

    ...
    /* Get a reference to the data decribing **fourth** image in the buffer filled by the example above. */
    const char * pBufferImage4 = *BufferImageGetByIndex(pBuffer, 3);
    
    /* Get the size ... */
    size_t sizeImage4 = *((size_t *) pBufferImage4);
    /* ... and a reference to the image data. */
    const char * pImage4 = pBufferImage4 + sizeof(size_t);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From my controller I am passing two instance variables @events = Event.all and @images
I have stereo cameras systems. In my program I catch the images from each
I receive a certain image name in a boundfield (i have two images in
I am using pictureBox to show images which are received from server but my
I receive a date in the format below from a json file. Im not
I have a main UIViewcontroller (vcMain) with two UIViewControllers subclassed from the main one.
I want to receive images from an IP camera over HTTP via GET request.
I have a central application which is going to receive messages from various services
I have a script I'm writing to batch download images from an imageboard via
I have this JSON Object which I receive from the api.moviedb.com It is pretty

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.