OpenCV之Point&Rect總結

#include "mainwindow.h"
#include <QApplication>
#include <QList>
#include <QDebug>
/*
 總結:Rect與Point等都只能是int類型,若是是是float,會自動轉換成整形
*/
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QList<Rect>RectList;
    float x = 10.33;
    float y = 10.0;
    float w = 300.123;
    float h = 300.45;
    Rect rect(x, y, w, h);
    qDebug() << rect.width << rect.height;  //300 300
    Point point(x, y);
    qDebug() << point.x << point.y; //10 10

    RectList.push_back(rect);
    for(auto it = RectList.begin(); it != RectList.end(); ++it)
    {
        (*it).x = (*it).x * 2;
        (*it).y = (*it).y / 2;
        qDebug() <<(*it).x  ;
    }
    qDebug() << RectList.back().x << RectList.back().y << RectList.back().width << RectList.back().height;
    waitKey();
    return a.exec();
}
相關文章
相關標籤/搜索