本文整理汇总了C++中Serial::send_data_tty方法的典型用法代码示例。如果您正苦于以下问题:C++ Serial::send_data_tty方法的具体用法?C++ Serial::send_data_tty怎么用?C++ Serial::send_data_tty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Serial
的用法示例。
在下文中一共展示了Serial::send_data_tty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
int detections = 1;
while(capture.read(frame)){
//<<<<<<<<<<<<<<
double timeMs=0;
timeMs=getTickCount();
//get frame
cvtColor(frame, current_gray, CV_RGB2GRAY);
//Process Frame
tld.processFrame(last_gray,current_gray,pts1,pts2,pbox,status,tl,bb_file);
//Draw Points
if (status){
drawPoints(frame,pts1);
drawPoints(frame,pts2,Scalar(0,255,0));
drawBox(frame,pbox);
detections++;
//drawWarning
static unsigned char count=0;
Rect symbol(Point(0,0),Size(frame.cols,frame.rows));
rectangle(frame,symbol.tl(),symbol.br(),Scalar(0,0,count),15);
putText(frame,"WARNING",Point(90,120),FONT_HERSHEY_SIMPLEX,1.2,CV_RGB(count,0,0),2);
count+=16;
//attach coordinate
ostringstream printText;
Rect detdObj;
detdObj.x=(pbox.x+pbox.width/2)/2;
detdObj.y=(pbox.y+pbox.height/2)/2;
printText<<"X:"<<detdObj.x<<" "<<"Y:"<<detdObj.y<<" "<<"Area:"<<pbox.width*pbox.height;
putText(frame,printText.str(),Point(20,40),FONT_HERSHEY_SIMPLEX,0.7,CV_RGB(100,255,0),2);
//send data through serial port
#ifdef SERIAL_PORT
static int sendRate=0;
if((sendRate++)%8==0)
{
sendBuff[0]=0xff;
sendBuff[1]=detdObj.x;
sendBuff[2]=detdObj.y;
sendBuff[3]=0xfe;
serial.send_data_tty(sendBuff,4);
}
#endif
//
}
else
{
//drawSafe
static unsigned char safeCount=0;
putText(frame,"Environment Safe",Point(20,20),FONT_HERSHEY_SIMPLEX,0.7,CV_RGB(0,safeCount,0),2);
safeCount+=16;
}
//Display
//<<<<<<<<<<<<<<
//double timeMs=0;
//timeMs=getTickCount();
//resize(frame,frame,Size(3*round(frame.cols),3*round(frame.rows)));
//timeMs=(getTickCount()-timeMs)/getTickFrequency();
//cout<<"<<<<<<<<<< "<<"Time: "<<timeMs*1000<<" >>>>>>>>>>"<<endl;
//>>>>>>>>>>>>>>
imshow("Intelisu", frame);
//Super Display
// Mat scaleImage;
// resize(frame,scaleImage,Size(2*round(frame.cols),2*round(frame.rows)));
// ostringstream printText;
// printText<<"X:"<<pbox.x+pbox.width/2<<" "<<"Y:"<<pbox.y+pbox.height/2;
// putText(scaleImage,printText.str(),Point(40,40),FONT_HERSHEY_SIMPLEX,1,CV_RGB(100,255,0),2);
// imshow("Intelisu", scaleImage);
//swap points and images
swap(last_gray,current_gray);
//clean the track
pts1.clear();//clean the
pts2.clear();
frames++;
//printf("Detection rate: %d/%d\n",detections,frames);
if ((char)waitKey(1) == 'q')
break;
timeMs=(getTickCount()-timeMs)/getTickFrequency();
cout<<"<<<<<<<<<< "<<"Time: "<<timeMs*1000<<" >>>>>>>>>>"<<endl;
}
fclose(bb_file);
return 0;
}