Go to Post Too bad MI isn't allowed to participate in FTC - Cory [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 27-01-2016, 22:36
jreneew2's Avatar
jreneew2 jreneew2 is online now
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 189
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
getting output from opencv onto smartdashboard

Hello. We are testing some vision code we wrote on the roboRIO and are using opencv on the RIO. I would like to be able to get the output steam of jpegs from opencv to the c++ smartdashboard.

I have seen you can use CameraServer's setImage, but how does that work in correlation with the smartdashboard?

Thanks,
Drew
Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2016, 11:54
mikhail's Avatar
mikhail mikhail is offline
Registered User
AKA: Mentor of The Software ERRORs
FRC #3130 (ERRORS)
Team Role: Mentor
 
Join Date: Dec 2014
Rookie Year: 2013
Location: Minnesota
Posts: 15
mikhail is an unknown quantity at this point
Re: getting output from opencv onto smartdashboard

SmartDashboard's and OpenCV's formats are not compatible with each others but there is a trick. There could be better methods but here's what worked for me, at least for debugging purposes. Save your cv::Mat, the one you want to see, probably after all the OpenCV processing with marks and numbers on it, using imwrite() somewhere in RoboRIO's filesystem. I used /var/volatile/tmp/ directory as I guess it's some kind of a RAM-disk on RoboRIO, so all the IO should happen in-memory. Then create an IMAQ image object, something like "Image image = frcCreateImage(IMAQ_IMAGE_RGB);", and read your file into it and set it as the current frame with the CameraServer:
Code:
void CameraFeedCommand::CameraFeedCommand()
{
    image = frcCreateImage(IMAQ_IMAGE_RGB);
}

void CameraFeedCommand::Execute()
{
    frcReadImage(image,"/var/volatile/tmp/opencv-frame.png"); 
    CameraServer::GetInstance()->SetImage(image);
}
PS: Do not run the automatic capture with the CameraServer, feed it the images yourself repeatedly.
PPS: Set the camera mode on the Dashboard to "USB camera HW"
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2016, 12:41
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 516
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: getting output from opencv onto smartdashboard

I wrote a MJPG streaming server in Java for our vision system and I have a more limited C++ version of it that I ported for a personal project, but it requires Boost, which might be a little difficult to get working on the roboRIO.

I attached them both to this post, in case they might be helpful.
Attached Files
File Type: java VideoServer.java (9.2 KB, 8 views)
File Type: cpp VideoServer.cpp (4.2 KB, 10 views)
File Type: h VideoServer.h (1.2 KB, 3 views)
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
Reply


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 09:59.

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