0

I have client and server, have an image in client and I want to send this to server. That image is in cv::mat format. Therefore I need to convert this matrix to binary. I have tried memcpy(binImage,matImg.data,sizeof(matImg.data) binImage's format is char*

How can i convert this matImg to binImg? I don't have any experience about OpenCV.

Ulfsark
  • 902
  • 1
  • 11
  • 26
  • See the answer here http://stackoverflow.com/questions/20314524/c-opencv-image-sending-through-socket/20321262#20321262 might be helpful. – Haris Mar 10 '14 at 16:54

1 Answers1

0

The following should do the trick:

memcpy(binImage, matImg.data, matImg.step.p[0]*matImg.rows)

However, I think you can avoid the copy and work directly with matImg.data.

BConic
  • 8,750
  • 2
  • 29
  • 55
  • @Darth This is only the instruction for `memcpy`. Did you allocated `binImage` with enough space ? Did you initialized `matImg` ? – BConic Mar 10 '14 at 18:06