68 lines
1.1 KiB
C++
68 lines
1.1 KiB
C++
|
#include "image.h"
|
||
|
|
||
|
Image::Image(){
|
||
|
filename="";
|
||
|
scale=1;
|
||
|
}
|
||
|
|
||
|
Image::Image(std::string _filename){
|
||
|
filename=_filename;
|
||
|
scale=1;
|
||
|
load();
|
||
|
}
|
||
|
|
||
|
Image::~Image(){
|
||
|
img.release();
|
||
|
}
|
||
|
|
||
|
std::string Image::getFilename(){
|
||
|
return filename;
|
||
|
}
|
||
|
|
||
|
cv::Mat* Image::getMat(){
|
||
|
return &img;
|
||
|
}
|
||
|
|
||
|
Point Image::getPosition(){
|
||
|
return position;
|
||
|
}
|
||
|
|
||
|
Point Image::getCrop1(){
|
||
|
return crop1;
|
||
|
}
|
||
|
|
||
|
Point Image::getCrop2(){
|
||
|
return crop2;
|
||
|
}
|
||
|
|
||
|
double Image::getScale(){
|
||
|
return scale;
|
||
|
}
|
||
|
|
||
|
void Image::setScale(double _scale){
|
||
|
scale=_scale;
|
||
|
}
|
||
|
|
||
|
void Image::setFilename(std::string _filename){
|
||
|
filename=_filename;
|
||
|
}
|
||
|
|
||
|
bool Image::load(){
|
||
|
img=cv::imread(filename, CV_LOAD_IMAGE_COLOR);
|
||
|
if(!img.data){
|
||
|
fprintf(stderr, "Error> Image can not be found or can not be loaded. At: Image::load() (file: %s, line: %d)\n", __FILE__, __LINE__);
|
||
|
return false;
|
||
|
}
|
||
|
crop2=Point(img.cols, img.rows);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
void Image::setPosition(Point _position){
|
||
|
position=_position;
|
||
|
}
|
||
|
|
||
|
void Image::setCrop(Point _crop1, Point _crop2){
|
||
|
crop1=_crop1;
|
||
|
crop2=_crop2;
|
||
|
}
|