ROS Code VideoCapture doesn't work on Intel NUC5i5MYBE
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 ...