Unable to get input from mvbluefox3 through a simple program!

asked 2020-06-26 11:16:24 -0500

bansi_lol gravatar image

Hi guys I am using a matrix vision bluefox 3 camera for autonomous applications but first i was trying to get the input from the camera through a simple c++ code which is below. But it doesn't work, means the result comes as cannot open the camera. I have the drivers of the camera installed and I am using ROS Melodic on VMWare Workstation 15.5. So what changes should I do ? I tried setting parameter pixel_format to yuyv and then run the rosrun command but it gave the same result. Here's the code i used.

include <ros ros.h="">

include <cv_bridge cv_bridge.h="">

include <opencv2 highgui="" highgui.hpp="">

include <iostream>

using namespace std; using namespace cv;

class cam_test{ public: cam_test(){ VideoCapture cap(CV_CAP_ANY); // open the video camera no. 0

       if (!cap.isOpened()) //if not sucess, exit prog
        {
             cout << "Cannot open the video cam" << endl;
        }
    double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); // get the width of the frames of the video
    double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); // get the height of the frames of the video

     cout << "Frame size : " << dWidth<< "x" << dHeight << endl;

     namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "myvideo"

     while (1)
     {
         Mat frame;
         bool bSuccess = cap.read(frame); //read a new frame from video

          if (!bSuccess) //if not sucess, break up
          {
            cout << " Cannot read a frame from video stream" << endl;
            break;
          }
              imshow("MyVideo", frame);

          if (waitKey(30)==27) //Wait for 'esc' keypress for 30ms. If 'esc' key is pressed, break loop
          {
               cout << "esc key was pressed by user" << endl;
               break;
          }

     }

  }

  ~cam_test(){
      cvDestroyWindow("Camera_Output");
  }

};

int main(int argc, char **argv) { //set up ROS. ros::init(argc, argv, "internal_cam_test"); cam_test cam_object;

ROS_INFO("Cam Tested");

}

edit retag flag offensive close merge delete