Conversion between rectangle types in the "OpenCV base" OpenCV and Dlib libraries

Source: Internet
Author: User

Objective

The recent use of the Dlib library will also use the OPENCV, especially because the Dlib library's drawing function is not familiar with, want to convert to OpenCV to show. This article describes the conversion between the rectangle types in the two open source libraries.

Type description

The rectangle functions in Cv::rect and OpenCV in OpenCV:

voidconst Scalar &int1int linetype =   int0)     

Or

void cv::rectangle (Mat &const Scalar &1   int Linetype =int0)         

Type of rectangle in Dlib:

   Long Long Long bottom_);

Or

Const vector<t,2>&const vector<t,2>& p2);

How to convert

Static cv::rect Dlibrectangletoopencv (Dlib::rectangle r) {    return11));}

Or

Static dlib::rectangle Opencvrecttodlib (Cv::rect r) {    return dlib::rectangle (long ) r.tl (). x, (long) r.tl (). Y, (long1, (long1);}

Or

DETS.L = detect_rect.x;dets. T = detect_rect.y;dets. R = detect_rect.x + detect_rect.width;dets . B = Detect_rect.y + detect_rect.height;

Where Detect_rect is the OpenCV type, dets is the dlib type;

Reference

The type of rect in 1.OPENCV;

The type of rectangle in 2.dlib;

3.stackoverflow-convert-opencvs-rect-to-dlibs-rectangle;

Conversion of the type format between 4.dlib and OpenCV;

Finish

Conversion between rectangle types in the "OpenCV base" OpenCV and Dlib libraries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.