Go to Post Admiring the new chassis: "Oooo, nerd bling!" - Rick TYler [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 02-13-2015, 03:38 PM
seabasssl seabasssl is offline
Registered User
FRC #3711
 
Join Date: Feb 2015
Location: Trout Lake, Washington
Posts: 9
seabasssl is an unknown quantity at this point
USB Camera on the SmartDashboard

Hey everyone! We've been having some issues with the USB camera not showing up on the SmartDashboard. Many of the threads I've read on here haven't given us any significant results, about our issue.

We are getting the "Huffman table not defined" error - we're running on a 64 bit OS. I had two cameras working the first time I tried it, and then the next day, we couldn't even get one to work.

There is a reading on the DriverStation, when the USB Camera HW option is selected, but no image display.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-14-2015, 05:26 AM
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 688
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: USB Camera on the SmartDashboard

Have you tried my solution? http://www.chiefdelphi.com/forums/sh...d.php?t=134404
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #3   Spotlight this post!  
Unread 02-14-2015, 02:21 PM
seabasssl seabasssl is offline
Registered User
FRC #3711
 
Join Date: Feb 2015
Location: Trout Lake, Washington
Posts: 9
seabasssl is an unknown quantity at this point
Re: USB Camera on the SmartDashboard

Thank you for your patch, seems like it's an awesome solution - but I'm not getting any visual from the camera still.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-15-2015, 04:28 AM
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 688
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: USB Camera on the SmartDashboard

Quote:
Originally Posted by seabasssl View Post
Thank you for your patch, seems like it's an awesome solution - but I'm not getting any visual from the camera still.
What code are you running on the robot to transmit the camera images to the driver station?

Just to clarify - are you using SmartDashboard or the LabVIEW/default dashboard?

Do you get the same error or a different one when you use my version of the applet? If you are getting an error with my applet, there should be files placed at C:\Users\<user name>\SmartDashboard\extensions\ named error.txt and frame.jpg. Can you upload them?

Thanks,
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #5   Spotlight this post!  
Unread 02-15-2015, 02:31 PM
seabasssl seabasssl is offline
Registered User
FRC #3711
 
Join Date: Feb 2015
Location: Trout Lake, Washington
Posts: 9
seabasssl is an unknown quantity at this point
Re: USB Camera on the SmartDashboard

I am using the Simple Vision example code
Code:
CameraServer::GetInstance()->SetQuality(50);
	CameraServer::GetInstance()->StartAutomaticCapture("cam0");
	CameraServer::GetInstance()->StartAutomaticCapture("cam1");

I added the "cam1", however, because we've been having issues with the RoboRIO not registering "cam0", but instead will just recognize the camera as cam1 and up.

On our prototype robot, we're having success with one camera - but not on our "final" robot, even when using the same RoboRIO, and code from our prototype robot.

We had success with both the SmartDashboard and the standard Driver Station on our prototype robot.

Here's the error log error.txt
The frame.jpg has no data in it.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-16-2015, 04:48 AM
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 688
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: USB Camera on the SmartDashboard

Try removing the first call to StartAutomaticCapture. From the source code for CameraServer, it looks like only the first call to StartAutomaticCapture will have any effect, so your code will be trying to stream from cam0.

See here for instructions on determining the names for your camera(s): http://wpilib.screenstepslive.com/s/...amera-C++\Java
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #7   Spotlight this post!  
Unread 02-17-2015, 10:27 AM
joliet cyborgs joliet cyborgs is offline
Registered User
FRC #4241
 
Join Date: Jan 2013
Location: Joliet
Posts: 4
joliet cyborgs is an unknown quantity at this point
Re: USB Camera on the SmartDashboard

Copying and pasting the code from the Image Processing example code worked for us. You just have to make sure to put each section of code in the right place.
Reply With Quote
  #8   Spotlight this post!  
Unread 02-17-2015, 12:52 PM
rod@3711 rod@3711 is offline
Registered User
AKA: rod nelson
FRC #3711 (Iron Mustangs)
Team Role: Mentor
 
Join Date: May 2014
Rookie Year: 2014
Location: Trout Lake, WA
Posts: 64
rod@3711 is an unknown quantity at this point
Re: USB Camera on the SmartDashboard

Just having one call to StartAutomaticCapture with the correct name (ie cam2) got things going. We will give up on getting 2 cameras going.

Now the image is seems overexposed. If I use change speed slider bar on dashboard, the image is good for one or 2 update, then back to overexposed. Any ideas?
Reply With Quote
  #9   Spotlight this post!  
Unread 02-17-2015, 05:17 PM
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 688
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: USB Camera on the SmartDashboard

Quote:
Originally Posted by rod@3711 View Post
Just having one call to StartAutomaticCapture with the correct name (ie cam2) got things going. We will give up on getting 2 cameras going.
You could modify the Intermediate Vision example to allow you to switch between cameras.

Code:
#include "WPILib.h"

/**
 * Uses IMAQdx to manually acquire a new image each frame, and annotate the image by drawing
 * a circle on it, and show it on the FRC Dashboard.
 */
class IntermediateVisionRobot : public SampleRobot
{
    IMAQdxSession camera1;
    IMAQdxSession camera2;
    Image *frame;
    IMAQdxError imaqError;

public:
    void RobotInit() override {
        SmartDashboard::PutBoolean("Camera Select", true);
        
        // create an image
        frame = imaqCreateImage(IMAQ_IMAGE_RGB, 0);
        
        //the camera name (ex "cam0") can be found through the roborio web interface
        imaqError = IMAQdxOpenCamera("cam0", IMAQdxCameraControlModeController, &camera1);
        if(imaqError != IMAQdxErrorSuccess) {
            DriverStation::ReportError("IMAQdxOpenCamera error: " + std::to_string((long)imaqError) + "\n");
        }
        imaqError = IMAQdxConfigureGrab(camera1);
        if(imaqError != IMAQdxErrorSuccess) {
            DriverStation::ReportError("IMAQdxConfigureGrab error: " + std::to_string((long)imaqError) + "\n");
        }
        
        //the camera name (ex "cam1") can be found through the roborio web interface
        imaqError = IMAQdxOpenCamera("cam1", IMAQdxCameraControlModeController, &camera2);
        if(imaqError != IMAQdxErrorSuccess) {
            DriverStation::ReportError("IMAQdxOpenCamera error: " + std::to_string((long)imaqError) + "\n");
        }
        imaqError = IMAQdxConfigureGrab(camera2);
        if(imaqError != IMAQdxErrorSuccess) {
            DriverStation::ReportError("IMAQdxConfigureGrab error: " + std::to_string((long)imaqError) + "\n");
        }
    }

    void OperatorControl() override {
        // acquire images
        IMAQdxStartAcquisition(camera1);
        IMAQdxStartAcquisition(camera2);

        // grab an image, draw the circle, and provide it for the camera server which will
        // in turn send it to the dashboard.
        while(IsOperatorControl() && IsEnabled()) {
            bool which = SmartDashboard::GetBoolean("Camera Select");
            IMAQdxSession& capture_cam = which ? camera1 : camera2;
            
            IMAQdxGrab(capture_cam, frame, true, NULL);
            if(imaqError != IMAQdxErrorSuccess) {
                DriverStation::ReportError("IMAQdxGrab error: " + std::to_string((long)imaqError) + "\n");
            } else {
                CameraServer::GetInstance()->SetImage(frame);
            }
            Wait(0.005);                // wait for a motor update time
        }
        // stop image acquisition
        IMAQdxStopAcquisition(camera1);
        IMAQdxStopAcquisition(camera2);
    }
};

START_ROBOT_CLASS(IntermediateVisionRobot);
If you want to stream cameras simultaneously, the easiest way would probably be to do some small modifications to the CameraServer class and the dashboard widget to configure different ports for the streams. Be careful about saturating the field bandwidth if you do that, though.

Quote:
Originally Posted by rod@3711 View Post
Now the image is seems overexposed. If I use change speed slider bar on dashboard, the image is good for one or 2 update, then back to overexposed. Any ideas?
I'm not sure what the 'speed' slider adjusts, but try changing the exposure on the camera. You may be able to do it through the RoboRIO's web interface (don't have one in front of me to check), but here's how you could do it in code:

Code:
CameraServer::GetInstance()->SetQuality(50);
std::shared_ptr<USBCamera> camera(new USBCamera("cam1", true));
camera->SetExposureManual(50); // change this value
camera->SetBrightness(50); // change this value
CameraServer::GetInstance()->StartAutomaticCapture(camera);
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #10   Spotlight this post!  
Unread 02-18-2015, 10:00 AM
rod@3711 rod@3711 is offline
Registered User
AKA: rod nelson
FRC #3711 (Iron Mustangs)
Team Role: Mentor
 
Join Date: May 2014
Rookie Year: 2014
Location: Trout Lake, WA
Posts: 64
rod@3711 is an unknown quantity at this point
Re: USB Camera on the SmartDashboard

Thanx Ryan, we will try those things on spare robot. The students have a bad case of Bag and Tag Burnout, so we will hit it on Saturday.
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 10:07 AM.

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