OpenCV Matrix To Binary Image

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.

Answers


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.


Need Your Help

CSS media queries different results

html css responsive-design styles media-queries

Why is a DIV displaying different on mobile phone and a resized desktop window?

Hadoop: reciprocal of hdfs dfs -text

hadoop command-line hdfs hadoop2

In Hadoop, the hdfs dfs -text and hdfs dfs -getmerge commands allow one to easily read contents of compressed files in HDFS from the command-line, including piping to other commands for processing ...