本文整理汇总了C++中cv::Rect::tl方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::tl方法的具体用法?C++ Rect::tl怎么用?C++ Rect::tl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Rect
的用法示例。
在下文中一共展示了Rect::tl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findTop
bool findTop(cv::Point& top, int& topVal, cv::Mat* src, cv::Rect rect){
cv::Point res(0, 0);
int x = 0, y = 0;
bool bFound = false;
topVal = 65535;
if (!src->empty()){
try
{
for (int i = rect.tl().y; i < rect.br().y; ++i){
for (int j = rect.tl().x; j < rect.br().x; ++j){
{
Int16 curVarVec = Convert::ToInt16((src->at<Int16>(cv::Point(j, i))) * 255.0f / 8191.0f);
if (curVarVec < topVal && curVarVec > 0)
{
topVal = curVarVec;
x = j;
y = i;
bFound = true;
}
}
}
}
}
catch(...)
{
// DO NOTHING
}
}
//ht.nNose = src->at<Int16>(0,0);
if(bFound) top = cv::Point(x,y);
return bFound;
}
示例2: contient
//retourne vrai si la boundingBox a contient la bounding box b
bool contient(cv::Rect a, cv::Rect b)
{
if ((a.tl().x < b.tl().x) &&
(a.tl().y < b.tl().y) &&
(a.br().x > b.br().x) &&
(a.br().y > b.br().y))
return true;
return false;
}
示例3: update
void BlobPeople::update(const cv::Rect& track) {
cur = toOf(track).getCenter();
smooth.interpolate(cur, 0.5);
height = track.tl().y-track.br().y;
bottom = track.br().y;
left = track.tl().x;
right = track.br().x;
}
示例4: drawFace
void TrackFace::drawFace(cv::Mat & frame, cv::Rect & face_n, string box_text)
{
rectangle(frame, face_n, CV_RGB(0,255,0),1);
int pos_x=std::max(face_n.tl().x-10, 0);
int pos_y=std::max(face_n.tl().y-10, 0);
putText(frame, box_text, Point(pos_x, pos_y), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0,255,0),2.0);
}
示例5: setRegion
void LevelTracker::setRegion(const cv::Rect &roi)
{
topLeft=roi.tl();
bottonRight=roi.br();
if(topLeft.x<bottonRight.x && topLeft.y<bottonRight.y)
regOk=true;
}
示例6: MapShape
vector<cv::Point2d> MapShape(cv::Rect original_face_rect,
const vector<cv::Point2d> original_landmarks, cv::Rect new_face_rect)
{
vector<cv::Point2d> result;
for (const cv::Point2d &landmark: original_landmarks)
{
result.push_back(landmark);
result.back() -= static_cast<cv::Point2d>(original_face_rect.tl());
result.back().x *=
static_cast<double>(new_face_rect.width) / original_face_rect.width;
result.back().y *=
static_cast<double>(new_face_rect.height) / original_face_rect.height;
result.back() += static_cast<cv::Point2d>(new_face_rect.tl());
}
return result;
}
示例7: addMouseObject
bool GeoMapEditor::addMouseObject( // пытаемся добавить новый объект вытянув или кликнув мышкой
cv::Rect& rect, // note: in-out -- подкручиваем ректангл по законам первого рождения для данного объекта
int flags )
{
if (objType() == "AGM_Segm")
{
Point xyTL = rect.tl();
Point xyBR = rect.br();
GeoSheet& sh = gm.sheets[ cur_sheet ];
Point2d enTL = sh.xy2en( xyTL );
Point2d enBR = sh.xy2en( xyBR );
AGM_Segm* ps = new AGM_Segm(enTL, enBR);
gm.objects.push_back(cv::Ptr<AGM_Segm>(ps));
}
else
{
Point xy = center( rect );
GeoSheet& sh = gm.sheets[ cur_sheet ];
Point2d en = sh.xy2en( xy );
AGM_Point* pp = new AGM_Point( en );
gm.objects.push_back(cv::Ptr<AGM_Point>(pp));
}
return true;
};
示例8: checkColision
static bool checkColision(const cv::Rect &a, const cv::Rect &b){
if (b.contains(a.tl())) return true;
if (b.contains(a.br())) return true;
if (b.contains(cv::Point(a.x+a.width,a.y))) return true;
if (b.contains(cv::Point(a.x,a.y+a.height))) return true;
return false;
}
示例9: init
bool Target::init(KVConfig *cfg, int id, const cv::Rect &roi, const cv::Mat &curr_gray,
double stamp, double min_dis_5frames, int min_pts, int max_feature_pts, double qualitylevel)
{
first_rc_ = roi;
outer_.x = 0, outer_.y = 0, outer_.width = curr_gray.cols, outer_.height = curr_gray.rows;
stamp_ = stamp;
cfg_ = cfg;
id_ = id;
min_dis_5frames_ = min_dis_5frames;
min_pts_ = min_pts;
stopped_dis_ = atof(cfg->get_value("pd_target_stopped_dis", "2.0"));
//int max_features_pts = atoi(cfg->get_value("pd_max_features_pts", "300"));
int max_features_pts = 200;
PTS pts;
//cv::goodFeaturesToTrack(curr_gray(roi), pts, max_feature_pts, qualitylevel, 1.5);
hi_goodFeaturesToTrack(curr_gray(roi), pts, 200, qualitylevel, 1.5);
if ((int)pts.size() < min_pts_) {
return false;
}
l2g(pts, roi.tl());
layers_.push_back(pts);
brc_ = roi;
last_rc_ = cv::boundingRect(pts);
return true;
}
示例10:
Face::Face(cv::Rect &r)
{
cv::Point tl = r.tl();
m_center = cv::Point(tl.x + r.width/2, tl.y + r.height/2);
m_width = r.width;
m_height = r.height;
m_weight = 1;
}
示例11: center
inline static cv::Point center(const cv::Rect &rc)
{
std::vector<cv::Point> pts;
pts.push_back(rc.tl());
pts.push_back(rc.br());
return center(pts);
}
示例12: draw_box
// A litte subroutine to draw a box onto an image
//
void draw_box(cv::Mat& img, cv::Rect box) {
cv::rectangle(
img,
box.tl(),
box.br(),
cv::Scalar(0x00, 0x00, 0xff) /* red */
);
}
示例13: rectHasBlankPixels
/** determine if a rectangle contains "blank" pixels **/
bool Cropper::rectHasBlankPixels(const cv::Rect &roi) {
Point2i tr(roi.x + roi.width - 1, roi.y);
Point2i bl(roi.x, roi.y + roi.height - 1);
Point2i br(roi.x + roi.width - 1, roi.y + roi.height - 1);
if(lineHasBlankPixels(roi.tl(), tr))
return true;
if(lineHasBlankPixels(tr, br))
return true;
if(lineHasBlankPixels(bl, br))
return true;
if(lineHasBlankPixels(roi.tl(), bl))
return true;
return false;
}
示例14: set
void Rectangle::set(const cv::Rect &_rect)
{
rect = _rect;
tl = _rect.tl();
br = _rect.br();
left->set(tl, cv::Point(tl.x, br.y));
top->set(tl, cv::Point(br.x, tl.y));
bottom->set(tl, cv::Point(tl.x, br.y));
right->set(cv::Point(br.x, tl.y), cv::Point(tl.x, br.y));
info.set(_rect);
}
示例15: rescale_facebox
/**
* @brief Scales and translates a facebox. Useful for converting
* between face boxes from different face detectors.
*
* To convert from V&J faceboxes to ibug faceboxes, use a scaling
* of 0.85 and a translation_y of 0.2.
* Ideally, we would learn the exact parameters from data.
*
* @param[in] facebox Input facebox.
* @param[in] scaling The input facebox will be scaled by this factor.
* @param[in] translation_y How much, in percent of the original facebox's width, the facebox will be translated in y direction. A positive value means facebox moves downwards.
* @return The rescaled facebox.
*/
cv::Rect rescale_facebox(cv::Rect facebox, float scaling, float translation_y)
{
// Assumes a square input facebox to work? (width==height)
const auto new_width = facebox.width * scaling;
const auto smaller_in_px = facebox.width - new_width;
const auto new_tl = facebox.tl() + cv::Point2i(smaller_in_px / 2.0f, smaller_in_px / 2.0f);
const auto new_br = facebox.br() - cv::Point2i(smaller_in_px / 2.0f, smaller_in_px / 2.0f);
cv::Rect rescaled_facebox(new_tl, new_br);
rescaled_facebox.y += facebox.width * translation_y;
return rescaled_facebox;
};