View Single Post
  #4   Spotlight this post!  
Unread 30-01-2015, 14:59
JML's Avatar
JML JML is offline
Jlyon
AKA: Jlyon
FRC #3044 (0xBe4)
Team Role: Programmer
 
Join Date: Oct 2012
Rookie Year: 2012
Location: 3044
Posts: 17
JML is an unknown quantity at this point
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) {

	byte[] pixels = ((DataBufferByte) i.getRaster().getDataBuffer()).getData();
	Mat img = new Mat();
	img = new Mat(new Size(i.getWidth(), i.getHeight()), CvType.CV_8UC3);
	img.put(0, 0, pixels);

	return img;
}