Go to Post Iteration is a necessary but not sufficient criteria to being a powerhouse team. - Chris is me [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 06-02-2015, 19:55
FleventyFive FleventyFive is offline
Registered User
FRC #4118
 
Join Date: Sep 2014
Location: Gainesville, FL
Posts: 23
FleventyFive is on a distinguished road
Program crashing when grabbing USB Camera frame + misc comm issues

I'm trying to work on vision code or at least displaying a camera feed on the dashboard, but the program crashes on the function where I set the camera server frame. I know about the StartAutomaticCapture function but I'm trying to actually have each frame in memory so I can threshold it or w/e. I have a command that executes this every update time (5 ms or whatever the default is).
Code:
	cam->GetImage(NIframe);

	CameraServer::GetInstance()->SetImage( NIframe );

	Wait(0.1);
This causes the program to crash. The DriverStation says there is no RobotCode until I redeploy it/restart the roborio. The debugger says it is on this line (66) of wpilib's CameraServer.cpp.
Code:
     
    while (start < dataSize - 1) {
      if (data[start] == 0xFF && data[start + 1] == 0xD8) break;
      else start++;
    }
The header file for this command declares these variables
Code:
	USBCamera *cam;
	Threshold *thresh;
	ColorImage *frame;
	Image *NIframe;
	BinaryImage *binaryFrame;
It's been pretty frustrating trying to figure this out. Any ideas? I'm not sure if I'm making an obvious mistake or this is actually an odd issue. Also, even without any vission stuff happening we seem to have communication drops for a second every once in a while, but this might just be low battery. Is my program perhaps too big? It is CommandBassed with like 10 command and 3 subsystems and a few PID loops. Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2015, 18:20
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Program crashing when grabbing USB Camera frame + misc comm issues

I'm a bit perplexed why you're trying to 'set' the camera frame at all. If you're looking to do image analysis, you'll want to 'get' the frame from the camera and then do analysis on it.

In the case of wanting it on the smartdashboard - that can be accomplished by adding the video pane to the smartdashboard directly. I think this is in the menus or it is a right-click on the dashboard to add it. No programming necessary.

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2015, 18:25
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Program crashing when grabbing USB Camera frame + misc comm issues

Quote:
Originally Posted by bob.wolff68 View Post
In the case of wanting it on the smartdashboard - that can be accomplished by adding the video pane to the smartdashboard directly. I think this is in the menus or it is a right-click on the dashboard to add it. No programming necessary.

bob
This is not true for the USB camera. You need code to forward the image.

OP, you should check to make sure that you are actually getting a non-null image of non-zero size back from your call to GetImage. If you are calling GetImage every 20ms that's 50FPS which the camera can't provide, I haven't played with this enough to know if that's why your having an issue, but it would be my first suspicion.
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2015, 18:48
FleventyFive FleventyFive is offline
Registered User
FRC #4118
 
Join Date: Sep 2014
Location: Gainesville, FL
Posts: 23
FleventyFive is on a distinguished road
Re: Program crashing when grabbing USB Camera frame + misc comm issues

Quote:
Originally Posted by RufflesRidge View Post
OP, you should check to make sure that you are actually getting a non-null image of non-zero size back from your call to GetImage. If you are calling GetImage every 20ms that's 50FPS which the camera can't provide, I haven't played with this enough to know if that's why your having an issue, but it would be my first suspicion.
This was my guess as well. How to I check if it is non-null? The WPILIB image class has no public functions or attributes at all. It's very confusing... like how can I convert between the Image returned from the USBcamera and the other wpilib image classes like ColorImage (which have public functions like thresholding or w/e)? The AxisCamera class has functions to return these other types of images, but not the USBcamera. Thanks for the help.
Reply With Quote
  #5   Spotlight this post!  
Unread 07-02-2015, 18:59
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Program crashing when grabbing USB Camera frame + misc comm issues

I know that I have to power cycle the roboRIO when I upload code it can find the camera sometimes.
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
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 14:04.

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