本文整理汇总了C++中Serial::print方法的典型用法代码示例。如果您正苦于以下问题:C++ Serial::print方法的具体用法?C++ Serial::print怎么用?C++ Serial::print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Serial
的用法示例。
在下文中一共展示了Serial::print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processImage
void processImage(cv::Mat& image, cv::Mat& image_gray) {
// alternative way is to grab, then retrieve; allows for
// multiple grab when processing below frame rate - v4l keeps a
// number of frames buffered, which can lead to significant lag
// m_cap.grab();
// m_cap.retrieve(image);
// detect April tags (requires a gray scale image)
//cv::cvtColor(image, image_gray, CV_BGR2GRAY);
process_flag = true;
cout<<"process begin"<<endl;
double t = tic();
double t0;
if (m_timing) {
t0 = tic();
}
vector<AprilTags::TagDetection> detections = m_tagDetector->extractTags(image_gray);
if (m_timing) {
double dt = tic()-t0;
cout << "Extracting tags took " << dt << " seconds." << endl;
}
// print out each detection
cout << detections.size() << " tags detected:" << endl;
for (int i=0; i<detections.size(); i++) {
print_detection(detections[i]);
}
// show the current image including any detections
if (m_draw) {
for (int i=0; i<detections.size(); i++) {
// also highlight in the image
detections[i].draw(image_gray);
}
imshow(windowName, image_gray); // OpenCV call
}
// optionally send tag information to serial port (e.g. to Arduino)
if (m_arduino) {
if (detections.size() > 0) {
// only the first detected tag is sent out for now
Eigen::Vector3d translation;
Eigen::Matrix3d rotation;
detections[0].getRelativeTranslationRotation(m_tagSize, m_fx, m_fy, m_px, m_py,
translation, rotation);
m_serial.print(detections[0].id);
m_serial.print(",");
m_serial.print(translation(0));
m_serial.print(",");
m_serial.print(translation(1));
m_serial.print(",");
m_serial.print(translation(2));
m_serial.print("\n");
} else {
// no tag detected: tag ID = -1
m_serial.print("-1,0.0,0.0,0.0\n");
}
}
cout<<"process end:"<<endl;
process_flag = false;
}