Camera programming issues

we are trying to run two cameras on a robotic and sometimes it will recognize one camera
sometimes it wont recognize any but it will never recognize both at the same time it says on the driver station that the cameras are being seen but it doesn’t show any video we think its a programming issue but we cant seem to find anything wrong with the code so if anyone can help please

Hi, how are you creating your 2 cameras in code, and how is the driverstation showing that they are seen. Are they both usb cameras?

this is how we got it coded but we may have got somthing wrong

#include <frc/Joystick.h>

#include <frc/Spark.h>

#include <frc/TimedRobot.h>

#include <frc/drive/DifferentialDrive.h>

#include <cameraserver/CameraServer.h>

#include <wpi/raw_ostream.h>

#include <frc/PWMVictorSPX.h>

#include <frc/SpeedController.h>

#include <frc/XboxController.h>

#include <frc/Servo.h>

class Robot : public frc::TimedRobot {

frc::Spark m_leftMotor{8};

frc::Spark m_rightMotor{9};

frc::PWMVictorSPX m_blowermotor{7};

frc::PWMVictorSPX m_shouldermotor{6};

frc::Servo clawservo{5};

frc::DifferentialDrive m_robotDrive{m_leftMotor, m_rightMotor};

frc::Joystick m_stick{0};

frc::Joystick m_box{1};

public:

void RobotInit() override {

#if defined(linux)

frc::CameraServer::GetInstance()->StartAutomaticCapture();

#else

wpi::errs() << “Vision only available on Linux.\n”;

wpi::errs().flush();

#endif

}

void TeleopPeriodic() {

// Drive with arcade style

m_robotDrive.ArcadeDrive(m_stick.GetY(), m_stick.GetX());

clawservo.Set(0);

if(m_stick.GetRawButton(1) == true) //runs fan

            {

                m_blowermotor.Set(1);

            }

if(m_stick.GetRawButton(1) == false) //stops fan

                    {

                        m_blowermotor.Set(0);

                    }

if(m_box.GetRawButton(2) == true) //raises arm

            {

                m_shouldermotor.Set(1);

            }

if(m_box.GetRawButton(4) == true) //lowers arm

            {

                m_shouldermotor.Set(-1);

            }

if(m_box.GetRawButton(2) == false && m_box.GetRawButton(4) == false) //arm does nothing

            {

                m_shouldermotor.Set(0);

            }

}

};

#ifndef RUNNING_FRC_TESTS

int main() { return frc::StartRobot<Robot>(); }

#endif

ReplyForward

this is in c++ on visual studio

Ok so I don’t know my way around c++ super well, however it appears you are only starting 1 camera with

frc::CameraServer::GetInstance()->StartAutomaticCapture();

Try using

frc::CameraServer::GetInstance()->StartAutomaticCapture(1);
frc::CameraServer::GetInstance()->StartAutomaticCapture(2);
1 Like

my mentor says your a genius and thank you

1 Like

wait

thx we were testing it wireless

it fixed the problem

No problem!