Ask Your Question

dinamex's profile - activity

2020-10-09 14:33:51 -0600 received badge  Popular Question (source)
2020-08-28 05:08:26 -0600 received badge  Popular Question (source)
2018-10-25 12:06:23 -0600 received badge  Notable Question (source)
2016-04-24 16:12:45 -0600 received badge  Popular Question (source)
2014-07-27 20:03:41 -0600 received badge  Student (source)
2012-12-19 13:33:32 -0600 asked a question No accelerated colorspace conversion found from yuv422p to rgb24

Hi all,

I would like to use the hardware enabled mjpeg compression of my webcam (Logitech c920). I'm using a Pandaboard (ARM) and ubuntu 11.10 Server. I use as camera driver the ROS usb_cam package which works with YUYV but when I change the pixelformat to MJPEG I'll get following warning.

[swscaler @ 0xe8d640] No accelerated colorspace conversion found from yuv422p to rgb24.

The camera works but has a big time difference between the output and the actual image (about 2-3 seconds). According to some googling this warning leads to some lag and is caused by some old dependencies. Therefore I installed ffmpeg-0.10.6, ffmpeg-0.6.2 & ffmpeg-0.6.6 all with the same result. I always rebuild OpenCV afterward. Is it a ffmpeg problem or is that caused by OpenCV?

This is my cmake configuration of OpenCV 2.3.1:
BUILD_DOCS ON
BUILD_EXAMPLES OFF
BUILD_NEW_PYTHON_SUPPORT ON
BUILD_PACKAGE ON
BUILD_SHARED_LIBS ON
BUILD_TESTS OFF
BUILD_WITH_DEBUG_INFO ON
BZIP2_LIBRARIES /usr/lib/libbz2.so
CMAKE_BACKWARDS_COMPATIBILITY 2.4
CMAKE_BUILD_TYPE RELEASE
CMAKE_CONFIGURATION_TYPES Debug;Release
CMAKE_INSTALL_PREFIX /usr/local
CMAKE_VERBOSE OFF
CUDA_BUILD_CUBIN OFF
CUDA_BUILD_EMULATION OFF
CUDA_SDK_ROOT_DIR CUDA_SDK_ROOT_DIR-NOTFOUND
CUDA_TOOLKIT_ROOT_DIR CUDA_TOOLKIT_ROOT_DIR-NOTFOUND
CUDA_VERBOSE_BUILD OFF
EIGEN_INCLUDE_PATH /usr/include/eigen3
ENABLE_PROFILING OFF
ENABLE_SOLUTION_FOLDERS OFF
EXECUTABLE_OUTPUT_PATH /home/panda/ros_workspace/OpenCV-2.3.1/release/bin
INSTALL_C_EXAMPLES OFF
INSTALL_PYTHON_EXAMPLES OFF
LIBRARY_OUTPUT_PATH /home/panda/ros_workspace/OpenCV-2.3.1/release/lib
OPENCV_BUILD_3RDPARTY_LIBS OFF
OPENCV_CONFIG_FILE_INCLUDE_DIR /home/panda/ros_workspace/OpenCV-2.3.1/release
OPENCV_EXTRA_C_FLAGS
OPENCV_EXTRA_C_FLAGS_DEBUG
OPENCV_EXTRA_C_FLAGS_RELEASE
OPENCV_EXTRA_EXE_LINKER_FLAGS
OPENCV_EXTRA_EXE_LINKER_FLAGS_
OPENCV_EXTRA_EXE_LINKER_FLAGS_
OPENCV_MANGLED_INSTALL_PATHS OFF
OPENCV_WARNINGS_ARE_ERRORS OFF
OPENEXR_INCLUDE_PATH OPENEXR_INCLUDE_PATH-NOTFOUND
OPENNI_INCLUDE_DIR /usr/include/ni
OPENNI_LIB_DIR /usr/lib
OPENNI_PRIME_SENSOR_MODULE_BIN /usr/lib
PVAPI_INCLUDE_PATH PVAPI_INCLUDE_PATH-NOTFOUND
PYTHON_PACKAGES_PATH lib/python2.7/dist-packages
USE_OMIT_FRAME_POINTER ON
USE_PRECOMPILED_HEADERS ON
WITH_1394 OFF
WITH_CUDA OFF
WITH_EIGEN ON
WITH_FFMPEG ON
WITH_GSTREAMER ON
WITH_GTK ON
WITH_IPP OFF
WITH_JASPER ON
WITH_JPEG ON
WITH_OPENEXR ON
WITH_OPENNI ON
WITH_PNG ON
WITH_PVAPI ON
WITH_QT OFF
WITH_QT_OPENGL OFF
WITH_TBB OFF
WITH_TIFF ON
WITH_UNICAP ON
WITH_V4L ON
WITH_XIMEA OFF
WITH_XINE OFF

my configuration options to install ffmpeg:
H.264 (git clone --depth 1 git://git.videolan.org/x264)
./configure --enable-static --enable-pic --enable-shared
make
sudo checkinstall --pkgname=libx264-dev --pkgversion="3:$(./version.sh | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes --fstrans=no --default

AAC audio encoder (git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git)
autoreconf -fiv
./configure --enable-pic --enable-shared
make
sudo checkinstall --pkgname=fdk-aac --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default

libvpx (git clone --depth 1 http://git.chromium.org/webm/libvpx.git)
./configure --enable-pic
make
sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default

FFmpeg (git clone --depth 1 git://source.ffmpeg.org/ffmpeg)
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-libvpx --enable-postproc --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-shared --enable-swscale --enable-pic
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="7:$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default
hash x264 ffmpeg ffplay ffprobe

2012-12-16 13:33:44 -0600 asked a question Use mjpeg compression

Hi all,

I would like to use the mjpeg compression of my webcam (logitech c920). I can see with $v4l2-ctl --list-formats that MJPEG is supported:

Output:

ioctl: VIDIOC_ENUM_FMT
Index       : 0
Type        : Video Capture
Pixel Format: 'YUYV'
Name        : YUV 4:2:2 (YUYV)

Index       : 1
Type        : Video Capture
Pixel Format: '' (compressed)
Name        : 34363248-0000-0010-8000-00aa003

Index       : 2
Type        : Video Capture
Pixel Format: 'MJPG' (compressed)
Name        : MJPEG

But I tried different ways to set the compression in my code but it doesn't work.

I tried:

cap.set(CV_CAP_PROP_FOURCC, 'M', 'J', 'P', 'G');

which leeds to the outputs that there are to many parameters. Therefore I changed to second parameter like this.

cap.set(CV_CAP_PROP_FOURCC, 2);

This leads to following output:

HIGHGUI ERROR: V4L: Property <unknown property string>(6) not supported by device
HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(6) - Invalid argument

Would be great to get your help. I appreciate any suggestions.

2012-12-16 13:24:25 -0600 received badge  Editor (source)
2012-12-14 18:58:27 -0600 asked a question Wrong resolution (video capture)

Hi all,

I'm using CV2.3.1 on a ARM Board and I would like to implement a webcam into my ROS project with MJPEG compression. But when I try to select a supported resolution (verified with $ v4l2-ctl --list-formats-ext) of 1920x1080 CV changes the resolution to 1600x896. Is there a specific reason our could it be possible that CV doesnt support this HD Webcam (Logitech c920). How can I see which resolutions are supported?



Here is my code:

#include "panda_kinect/OpenCVTools.h"
#include "ros/ros.h"
#include "image_transport/image_transport.h"
#include "sensor_msgs/CompressedImage.h"

int main(int argc, char *argv[])
{
        // init ros
        ros::init(argc, argv, "WebcamServer");

        ros::NodeHandle nh;
        image_transport::ImageTransport it(nh);

        image_transport::Publisher pub = it.advertise("/panda_cam/image_raw", 1);
        //ros::Publisher pub = nh.advertise<sensor_msgs::CompressedImage>("/camera/rgb/image_color/compressed", 1);

        bool show_fps;
        double desired_fps;
        nh.param<bool>("/WebcamServer/show_fps", show_fps, false);
        nh.param<double>("/WebcamServer/fps", desired_fps, 30.0);
        double fps = 0.0;
        int fpsCount = 0;

        ros::Rate rate(desired_fps);

        cv::VideoCapture cap(CV_CAP_V4L);
        cap.set(CV_CAP_PROP_FRAME_WIDTH,1920);
        cap.set(CV_CAP_PROP_FRAME_HEIGHT,1080);
        //cap.set(CV_CAP_PROP_FOURCC, 'M', 'J', 'P', 'G');


        if (cap.isOpened() == false)
        {
                ROS_ERROR("Failed to open webcam.");
                return 0;
        }

        //int frameCount = 0;
        while (ros::ok())
        {
                rate.sleep();

                if (show_fps && cap.isOpened())
                {
                        double cycleTime = rate.cycleTime().toSec();
                        if (cycleTime != 0.0)
                        {
                                fps += (1.0 / cycleTime);
                                fpsCount++;

                                if (fpsCount == 10)
                                {
                                        ROS_INFO("Rate: %lf", std::min(desired_fps, fps / fpsCount));
                                        fps = 0.0;
                                        fpsCount = 0;
                                }
                        }
                }

                if (pub.getNumSubscribers())
                {
                        cv::Mat frame;
                        frame.cols = 1920;
                        frame.rows = 1080;
                        cap >> frame;
                        pub.publish(OpenCVTools::matToImage(frame));

                        sensor_msgs::CompressedImage rgb_c;
                        rgb_c.header.stamp = ros::Time::now();
                        std::vector<int> p;
                        p.push_back(CV_IMWRITE_JPEG_QUALITY);
                        p.push_back(95);
                        cv::imencode(".jpg", frame, rgb_c.data, p);

                        //pub.publish(rgb_c);

                        /*
                        char path[255];
                        sprintf(path,"/home/scrusr/ros/panda_kinect/bin/images/frame%.4d.jpg", frameCount);
                        frameCount++;
                        cv::imwrite(path, frame);
                        */
                }

                ros::spinOnce();
        }
}