![]() |
OpenCV USBCamera convert to Mat
Our team is trying to do Driver Station image processing from a Microsoft lifecam HD-3000 HD USB camera which is plugged into the robot. We began working with the camera connected to the laptop, converting to and from a BufferedImage with
Code:
public static Mat bufferedImageToMat(BufferedImage i){Any assistance would be greatly appreciated. |
Re: OpenCV USBCamera convert to Mat
Sorry for the reply to my own thread. Does anyones team use opencv, or know a better way to retrieve images from the usb camera then using the code from SmartDashboard's USB Camera viewer class
|
Re: OpenCV USBCamera convert to Mat
If you're running OpenCV on the RRio itself create a VideoCapture object then call the read/retrieve method to put it into a Mat.
|
Re: OpenCV USBCamera convert to Mat
Thanks for the reply, we are currently using OpenCV on the Driver Station, and would prefer to do processing there in order to save RoboRIO CPU for max output and reaction speed. We are using the function from the Smart Dashboard camera viewer in order to get the image from the camera. This works well and gives us a BufferedImage of type TYPE_3BYTE_BGR. We can display the image perfectly fine through a simple gui. The problem is with our bufferedImageToMat(Mat img) function:
Code:
public static Mat bufferedImageToMat(BufferedImage i){ |
Re: OpenCV USBCamera convert to Mat
Quote:
|
Re: OpenCV USBCamera convert to Mat
I don't believe this is the typical way of converting a Mat to a BufferedImage. From my experience it is much similar to use MatOfByte:
Code:
// Lots of code...(I noticed you used this algorithm, but I will leave it here for future reference) http://stackoverflow.com/questions/1...-mat-in-opencv Is there some limitation where you can't use MatOfByte? |
Re: OpenCV USBCamera convert to Mat
1 Attachment(s)
I attached a screenshot of how the images come out with my current method after converting from BufferedImage to Mat, im going to try with the MatOfBte Method and see if that works, thanks for the help
|
Re: OpenCV USBCamera convert to Mat
Quote:
|
Re: OpenCV USBCamera convert to Mat
For whatever reason, switching the Mat Declaration to the one shown seemed to fix the problem, for anyone who finds this in the future.
Code:
public static Mat bufferedImageToMat(BufferedImage i) { |
| All times are GMT -5. The time now is 01:39. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi