title: Raw BGR image after JPG compression is the same length?
body: <p>Ok. This is a bit odd. Long story short. I am fething raw BGR images from a camera, compressing them to JPG with OpenCV and sending with UDP protocol to a PC. This is how I compress images:</p>
  
  <pre><code>// memblock contains raw image
  IplImage* fIplImageHeader;
  fIplImageHeader = cvCreateImageHeader(cvSize(160, 120), 8, 3);
  fIplImageHeader-&gt;imageData = (char*) memblock;
  
  // compress to JPG
  vector&lt;int&gt; p;
  p.push_back(CV_IMWRITE_JPEG_QUALITY);
  p.push_back(75);
  vector&lt;unsigned char&gt; buf;
  cv::imencode(".jpg", fIplImageHeader, buf, p);
  </code></pre>
  
  <p>This is how I send them with UDP:</p>
  
  <pre><code>n_sent = sendto(sk,&amp;*buf.begin(),(int)size,0,(struct sockaddr*) &amp;server,sizeof(server));
  </code></pre>
  
  <p>This is how I receive them in a PC:</p>
  
  <pre><code>int iRcvdBytes=recvfrom(iSockFd,buff,bufferSize,0,
  (struct sockaddr*)&amp;cliAddr,(socklen_t*)&amp;cliAddrLen);
  // print how many bytes we have received
  cout&lt;&lt;"Received "&lt;&lt;iRcvdBytes&lt;&lt;" bytes from the client"&lt;&lt;endl;
  </code></pre>
  
  <p>I am getting this output:</p>
  
  <pre><code>    Received 57600 bytes from the client
      Received 57600 bytes from the client
      ...
  </code></pre>
  
  <p>If I remove the JPG compression at the program fetching images from camera, the output is the same:</p>
  
  <pre><code>    Received 57600 bytes from the client
      Received 57600 bytes from the client
      ...
  </code></pre>
  
  <p>However, when I save the received image on a disk, it's size is around 7.8KB while uncompressed raw image saved to disk takes about 57KB space.</p>
  
  <p>What's going on here?</p>