Ask Your Question

pranith12's profile - activity

2014-02-27 02:33:09 -0600 received badge  Nice Answer (source)
2014-02-27 02:21:11 -0600 received badge  Famous Question (source)
2014-02-18 05:58:41 -0600 received badge  Nice Question (source)
2014-02-18 04:29:46 -0600 received badge  Teacher (source)
2013-09-10 13:12:19 -0600 received badge  Notable Question (source)
2013-06-11 05:06:44 -0600 received badge  Popular Question (source)
2013-03-23 16:57:02 -0600 received badge  Self-Learner (source)
2012-12-03 22:11:27 -0600 commented answer Mat to byte array

This method is throwing an error: OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/pranith/devops/code/opencv.git/opencv/modules/imgproc/src/color.cpp, line 3326 329809 [pool-2-thread-2] WARN org.apache.avro.ipc.Responder - user error

2012-12-03 12:36:55 -0600 received badge  Editor (source)
2012-12-03 12:35:12 -0600 answered a question Mat to byte array

This is how I did it: byte[] to Mat:

        byte[] raw_data = ...;
        Mat mat = new Mat();
        mat.put(0, 0, raw_data);

Mat to byte[]:

        byte[] return_buff = new byte[(int) (result_mat.total() * 
                                            result_mat.channels())];
        result_mat.get(0, 0, return_buff);
2012-12-03 12:32:56 -0600 received badge  Supporter (source)
2012-12-03 02:32:48 -0600 received badge  Student (source)
2012-11-30 14:28:13 -0600 asked a question Mat to byte array

I am trying to convert a Mat object to a byte array to transfer over a network. How do I achieve this? I am trying to do this in Java.