Created
February 18, 2014 16:28
-
-
Save lecram/9074285 to your computer and use it in GitHub Desktop.
Exemplo de utilização da classe cv::Rect para extrair uma região de interesse (ROI) de uma imagem.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* g++ -o exrect `pkg-config --libs opencv` exrect.cpp */ | |
#include <iostream> | |
#include "opencv2/opencv.hpp" | |
using namespace std; | |
using namespace cv; | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 2) { | |
cout << "usage:" << endl << argv[0] << " input" << endl; | |
return 1; | |
} | |
Mat img1, img2; | |
Rect r(240, 230, 70, 60); | |
img1 = imread(argv[1]); | |
r += Point(70, 0); | |
//r += Size(0, 100); | |
img2 = img1(r); | |
cvtColor(img2, img2, CV_BGR2GRAY); | |
namedWindow("Janela1"); | |
namedWindow("Janela2"); | |
//resize(img1, img1, Size(400, 400)); | |
//resize(img2, img2, Size(400, 400)); | |
imshow("Janela1", img1); | |
imshow("Janela2", img2); | |
moveWindow("Janela1", 0, 0); | |
moveWindow("Janela2", r.x, r.y); | |
while (waitKey(100) != 'q'); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment