![]() |
Get image from USBCamera into an OpenCV Mat
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: Code:
USBCamera cam = new USBCamera("cam0");Code:
ByteBuffer buf = ByteBuffer.allocate(76800); |
Re: Get image from USBCamera into an OpenCV Mat
Have you treid using the VideoCapture class from the OpenCV Java libs to open the USB camera instead of the WPI USBCamera class?
Maybe something like: Code:
VideoCapture vc = new VideoCapture();If you are able to open the camera this way, you should be able to grab your OpenCV Mat objects via: Code:
if (vc.grab()) {If you then need to take the Mat and go back to a BufferedImage, here is a snippet of what we use: Code:
public BufferedImage toBufferedImage(Mat img) { |
Re: Get image from USBCamera into an OpenCV Mat
That looks pretty good I'll check it out tonight.
|
Re: Get image from USBCamera into an OpenCV Mat
Worked beautifully. Writing a white paper now.
|
| All times are GMT -5. The time now is 09:12. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi