View Single Post
  #5   Spotlight this post!  
Unread 29-01-2015, 20:43
Adam8234's Avatar
Adam8234 Adam8234 is offline
Controls Captain
AKA: Adam Corpstein
FRC #2052 (KnightKrawler)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: United States
Posts: 28
Adam8234 will become famous soon enough
Re: OpenCV USBCamera convert to Mat

Quote:
Originally Posted by JML View Post
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){
		byte[] pixels = ((DataBufferByte) i.getRaster().getDataBuffer()).getData();
		Mat img = new Mat(i.getWidth(),i.getHeight(), CvType.CV_8UC3);
		img.put(0, 0, pixels);

		return img;
	}
However this is exactly the same as many of the online examples, if anyone has any ideas that would be appreciated. Also, what does everyone think about using OpenCV on the roboRio
This seems odd. Can you provide some screenshots?