rpappa
03-02-2016, 21:24
I've successfully put opencv on the Roborio and have tested to make sure it works (will do a write up on that soon™). However, I have run into the roadblock of the fact that the USBCamera class has no apparent way to get a straight up Java Image or BufferedImage or something easy to pass to Mat.put().
Here's my code which crashes:
USBCamera cam = new USBCamera("cam0");
cam.openCamera();
cam.startCapture();
ByteBuffer buf = ByteBuffer.allocate(76800);
cam.getImageData(buf);
matOriginal = new Mat();
matOriginal.put(0, 0, buf.array());
Imgcodecs.imwrite("output.png", matOriginal);
The line that crashes it is probably
ByteBuffer buf = ByteBuffer.allocate(76800);
But I'm not sure if that matters as I don't believe I am approaching this problem the right way. Any suggestions?
Here's my code which crashes:
USBCamera cam = new USBCamera("cam0");
cam.openCamera();
cam.startCapture();
ByteBuffer buf = ByteBuffer.allocate(76800);
cam.getImageData(buf);
matOriginal = new Mat();
matOriginal.put(0, 0, buf.array());
Imgcodecs.imwrite("output.png", matOriginal);
The line that crashes it is probably
ByteBuffer buf = ByteBuffer.allocate(76800);
But I'm not sure if that matters as I don't believe I am approaching this problem the right way. Any suggestions?