Mat of Byte to Array falling

42 views
Skip to first unread message

shira Jacobs

unread,
Feb 8, 2023, 4:28:25 AM2/8/23
to javacv

//Encoding the image
Loader.load(opencv_java.class) ;
MatOfByte matOfByte = new MatOfByte();
byte[] byteArray = matOfByte.toArray();

running the above code getting this error: 


Native Mat has unexpected type or size: Mat [ -1*-1*CV_8UC1, isCont=false, isSubmat=false, nativeObj=0x20e66d30130, dataAddr=0x0 ]

shira Jacobs

unread,
Feb 8, 2023, 4:38:05 AM2/8/23
to javacv
It's very important for me 
did not find any answer on goggle, 
can any one assist me, please?? 
ב-יום רביעי, 8 בפברואר 2023 בשעה 11:28:25 UTC+2, ‪shira Jacobs‬‏ כתב/ה:

Keith Hall

unread,
Feb 8, 2023, 6:54:38 AM2/8/23
to jav...@googlegroups.com
I'm not at my PC to check but it looks like you're basically trying to create a byte array from an empty MatOfByte. Try pushing some bytes into the  MatOfByte

--

---
You received this message because you are subscribed to the Google Groups "javacv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacv+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/javacv/2a1021e9-3cdc-414c-b64f-d0b43248946an%40googlegroups.com.

Keith Hall

unread,
Feb 8, 2023, 1:30:53 PM2/8/23
to javacv
So this might be one way of doing it

Loader.load(opencv_java.class);
String imageName = "dog.jpg";
Mat image = imread("images/" + imageName);
MatOfByte buffer = new MatOfByte();
// encode the image in the buffer, according to the PNG format
Imgcodecs.imencode(".png", image,  buffer);

shira Jacobs

unread,
Feb 18, 2023, 3:55:52 PM2/18/23
to jav...@googlegroups.com
Hey @Keith Hall 
Thank you!! very much appreciated!!

‫בתאריך יום ד׳, 8 בפבר׳ 2023 ב-20:30 מאת ‪Keith Hall‬‏ <‪the.kei...@gmail.com‬‏>:‬
You received this message because you are subscribed to a topic in the Google Groups "javacv" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/javacv/-YiA2x1zW5w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to javacv+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/javacv/43d382fc-c2f5-49dc-aa1c-bd8a28c1f84fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages