Ask Your Question
0

ROS Code VideoCapture doesn't work on Intel NUC5i5MYBE

asked 2018-01-30 23:11:22 -0500

Radeshwar gravatar image

updated 2018-02-01 22:50:14 -0500

jayess gravatar image

Hi,

I am using Intel NUC5i5MYBE for my application.

I have my code for the VideoCapture from USB Camera and it is tested and working perfectly in my Intel i5 PC. However I am using the same code in INTEL NUC5i5MYBE but I am getting few errors regarding VideoCapture.

The screenshorts of mode and the errors are attached below.

The Code

 #ifdef CAMERA_INTERFACE
 void *socket_server::display(void *ptr)
 {
uchar *buffer;
int bytes = 0;
int chkBytesRecv = 0;
int sendFlag = 0;
//VideoCapture cap(0);   
int socket = videoRemoteSocket;
int numBytesAvailable = 0;
unsigned char dataBuffer[200000] = {0};
unsigned char  *buffer1 = &dataBuffer[0];
FILE *in;
/*OpenCV Code*/

Mat img, imgGray;
img = Mat::zeros(480 , 640 , CV_8UC3);

int imgSize = img.total() * img.elemSize()  ;

if ( ! img.isContinuous() )
{
    img = img.clone();
    imgGray = img.clone();
}

cap.set(CV_CAP_PROP_POS_MSEC, 10); //start the video   

double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video    

while(1)
{
    if(connectionVideoFormed == 1)
    {


    /* get a frame from camera */
    cap >> img;   
    //cout<<"inside display():"<< socket <<endl;
    //while (1)
    //{



    //sleep(5);

    vector<int> compression_params; //vector that stores the compression parameters of the image

    compression_params.push_back(CV_IMWRITE_JPEG_QUALITY); //specify the compression technique

    compression_params.push_back(98); //specify the compression quality

    bool bSuccess = imwrite(jpegImage.c_str(), img, compression_params); //write the image to file


    /*****IF connection is there then only send data*************/


    //if(videoStremingOnOff == 1)
    //{ 

        in = fopen(jpegImage.c_str(),"rb");


        if(in != NULL)
        {


            fseek(in,0,SEEK_END);
            unsigned int size = ftell(in);
            unsigned char size_char = (unsigned char)size;
            unsigned int temp_size = htonl(size);

            fseek(in,0,SEEK_SET);       


            //cout<<"image size 1 = "<<size<<endl;
            //cout<<"image size 2 = "<<temp_size<<endl;

            //memset(buffer1,0,sizeof(buffer1));

            int byte_read=fread(buffer1, sizeof(unsigned char), size , in);


            if ((bytes = send(socket, &temp_size, 4, 0)) < 0)                   
            {

                cout<<"video_size sending failed"<<endl;
                connectionVideoFormed = 0;
                close(videoRemoteSocket);

            }
            else
            {
                //cout<<"video_size sending successful:"<<temp_size<<endl;

            }
            if ((bytes = send(socket, buffer1, size, 0)) < 0)

            {
                cout<< "video sending failed" <<endl;
                connectionVideoFormed = 0;
                close(videoRemoteSocket);
            }
            else
            {
                //cout<< "video sending successful"<<endl;


            }

            //bzero(&iptr[bytesToShift], ((sizeof(iptr))- bytesToShift));

        }
        fclose(in);         

    /*}
    else
    {
        //cout<<"Video streaming off"<<endl; 

    } */


    }
    usleep(100000);

}


 }
 #endif

Error

 [100%] Linking CXX executable /home/icrs/manipulator_proj/devel/lib/dynamixel_control/server_node
 CMakeFiles/server_node.dir/src/server.cpp.o: In function `socket_server::display(void*)':
 server.cpp:(.text+0x180): undefined reference to `cv::VideoCapture::VideoCapture(int)'
 server.cpp:(.text+0x313): undefined reference to `cv::VideoCapture::set(int, double)'
 server.cpp:(.text+0x327): undefined reference to `cv::VideoCapture::get(int) const'
 server.cpp:(.text+0x347): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
 server.cpp:(.text+0x685): undefined reference to `cv::VideoCapture::~VideoCapture()'
 collect2: error: ld returned 1 exit status
 dynamixel_control/CMakeFiles/server_node.dir/build.make:129: recipe for target '/home/icrs/manipulator_proj/devel/lib/dynamixel_control/server_node' failed
 make[2]: *** [/home/icrs/manipulator_proj/devel/lib/dynamixel_control/server_node] Error 1
 CMakeFiles/Makefile2:391: recipe for target 'dynamixel_control/CMakeFiles/server_node.dir/all' failed
 make[1]: *** [dynamixel_control/CMakeFiles/server_node.dir/all] Error 2
 Makefile:138: recipe for target 'all' failed
 make: *** [all] Error 2
 Invoking "make -j4 -l4" failed

Below is my CMakeList.txt file content

 cmake_minimum_required ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-01-31 00:50:59 -0500

mgruhler gravatar image

This points to some missing dependencies. Are you sure you have the dependencies, especially opencv, installed?

edit flag offensive delete link more

Comments

I didn't install Opencv separately, I installed ROS Kinetic. Do I need to install OpenCv separately???

Radeshwar gravatar imageRadeshwar ( 2018-01-31 01:57:51 -0500 )edit

Well, but which packages... If you install e.g. ros-kinetic-cv-bridge will automatically install opencv3. Check out the ROS wiki for more Details. Also, rosdep could help you in resolving dependencies, as Long as they are specified correctly.

mgruhler gravatar imagemgruhler ( 2018-01-31 04:50:14 -0500 )edit

hi mig

we installed cv_bridge and opencv3.4 along with ros-kinetic . we found that the same code is running on different PC installed with opencv2.4.9 so we also installed opencv2.4.9 in our intel NUC board however the result remain unchanged (same error)

Radeshwar gravatar imageRadeshwar ( 2018-01-31 06:34:43 -0500 )edit

@Radeshwar: ROS comes with a specific version of OpenCV. Installing OpenCV yourself is not recommended (until you get more comfortable with all of this).

gvdhoorn gravatar imagegvdhoorn ( 2018-01-31 06:43:27 -0500 )edit

hi gvdhoorn

we tried with default version of opencv that comes with ros-kinetic but we are getting the Videocapture error . so we wanted to try different version of opencv ,however the result was same(videocapture error)

Radeshwar gravatar imageRadeshwar ( 2018-01-31 07:24:02 -0500 )edit

Unless you overwrote the ROS distributed version or overrode the version found by CMake it might not have used the parallel installated versions.

gvdhoorn gravatar imagegvdhoorn ( 2018-01-31 07:32:47 -0500 )edit

Please add the contents of your CMakeLists.txt to your original question. Please use the Preformatted Text button to format it properly and please don't include all the comments. They are not needed.

gvdhoorn gravatar imagegvdhoorn ( 2018-01-31 07:33:29 -0500 )edit

I have added my CMakeList.txt file content to my question. I have not removed comments because I am not sure whether I have commented any required commands which is necessary. Kindly go through. Thanks.

Radeshwar gravatar imageRadeshwar ( 2018-02-01 22:37:09 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-01-30 23:11:22 -0500

Seen: 231 times

Last updated: Feb 01 '18