ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

error setting pixformat [closed]

asked 2015-06-02 22:28:57 -0500

Keiser30 gravatar image

Regards.

I'm using Roscpp + opencv (Ros-Hydro), which have connected my webcam via USB port and when you want to perform the capture of images of the camera gives me the following errors

  • libv4l2: error setting pixformat: Device or resource busy
  • HIGHGUI ERROR: unable to ioctl libv4l S_FMT
  • libv4l2: error setting pixformat: Device or resource busy
  • libv4l1: error setting pixformat: Device or resource busy
  • libv4l2: error setting pixformat: Device or resource busy
  • libv4l1: error setting pixformat: Device or resource busy
  • HIGHGUI ERROR: unable to ioctl libv4l VIDIOCSPICT

code_sistema_visual: /home/user/catkin_ws/src/beginner_tutorials/src/code_sistema_visual.cpp:173: int main(int, char): Assertion `cam' failed. Aborted (core dumped)

Not if someone could give me some solution to the problem.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Keiser30
close date 2016-07-02 11:27:45.047337

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-02 11:24:35 -0500

Keiser30 gravatar image

You must use the CvCapture, I used the part of the tutorial images Converting Between ROS and OpenCV images, which is in this link

And that can be seen below in the code, and the part that is highlighted is the one that gets the image.

void imageCb(const sensor_msgs::ImageConstPtr& msg)
  {
    cv_bridge::CvImagePtr cv_ptr;
    try
    {
      **cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);**
    }
    catch (cv_bridge::Exception& e)
    {
      ROS_ERROR("cv_bridge exception: %s", e.what());
      return;
    }

    // Draw an example circle on the video stream
    if (cv_ptr->image.rows > 60 && cv_ptr->image.cols > 60)
      cv::circle(cv_ptr->image, cv::Point(50, 50), 10, CV_RGB(255,0,0));

    // Update GUI Window
    **cv::imshow(OPENCV_WINDOW, cv_ptr->image);**
    cv::waitKey(3);

    // Output modified video stream
    image_pub_.publish(cv_ptr->toImageMsg());
  }
};
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-02 22:28:57 -0500

Seen: 1,214 times

Last updated: Jul 02 '16