Go to Post I think that one of the most fantastic parts about FIRST is that the biggest and most successful teams are also the most abiding to the rules. - Matt Adams [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 03-02-2016, 21:24
rpappa rpappa is offline
Registered User
FRC #0340
 
Join Date: Feb 2016
Location: Rochester
Posts: 8
rpappa is an unknown quantity at this point
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");
        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
Code:
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?
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi