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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:19:56+00:00 2026-05-18T08:19:56+00:00

This is part of my program: // let’s get jpg image from socket int

  • 0

This is part of my program:

// let's get jpg image from socket
int iRcvdBytes=recvfrom(iSockFd, buff, bufferSize, 0, 
(struct sockaddr*)&cliAddr, (socklen_t*)&cliAddrLen);

// buff now contains 30KB jpg image

// let's load the jpg image to IplImage
IplImage* fIplImageHeader;
fIplImageHeader = cvCreateImageHeader(cvSize(640, 480), 8, 1);
fIplImageHeader->imageData = (char *)buff;

// now let's check the size difference
cout << "Received " << iRcvdBytes << " bytes from the client" << endl;
cout << fIplImageHeader->imageSize << endl;

And the output is:

Received 31860 bytes from the client
307200

Now why is that? Is cvCreateImageHeader() converting the jpg image to RGB or something like that internally? I want it to stay JPG and show it with cvShowImage().

Please, any help would be welcome.

  • 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-18T08:19:57+00:00Added an answer on May 18, 2026 at 8:19 am

    You are comparing the lenght of the compressed jpeg image data to the uncompressed pixel data.

    In particular, given:

    fIplImageHeader = cvCreateImageHeader(cvSize(width, height), depth, channels) 
    

    It will always be the case that fIplImageHeader->imageSize == width * height * (depth/8) * channels

    Assigning the bytes recieved by the recvfrom() call to the imageData area doesn’t work in the first place.

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

Sidebar

Related Questions

I'd like to know what you think about this part of our program is
So I have a program which runs. This is part of the code: FileName
This is the last part of the program I am working on. I want
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
For some reasons this part where I fetch JSON data from following url will
Let me establish that this is part of a class assignment, so I'm definitely
Hi Android developers, I need a class for a part of my program. Let
Let's say you have to [write from scratch, rewrite, refactor] a sample program illustrating
I want to insert nodes which are fetched from other part of the program
This is a 2 part question. 1) Is there some sort of program that

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.