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.

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@Darth This is only the instruction for memcpy. Did you allocated binImage with enough space ? Did you initialized matImg ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.