-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathutils.cpp
30 lines (25 loc) · 1.01 KB
/
utils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "utils.h"
utils::utils()
{
}
utils::~utils()
{
}
std::string utils::csv_path = "./res/face.csv";
//std::string utils::haar_path = "./res/haarcascade_frontalface_alt.xml";
std::string utils::haar_path = "./res/lbpcascade_frontalface.xml";
//std::string utils::haar_path = "./res/cascade.xml";
QImage utils::convertMat2QImage(cv::Mat &img_cv) {
cv::Mat temp; // make the same cv::Mat
cvtColor(img_cv, temp,CV_BGR2RGB); // cvtColor Makes a copt, that what i need
QImage dest((const uchar *) temp.data, temp.cols, temp.rows, temp.step, QImage::Format_RGB888);
dest.bits(); // enforce deep copy, see documentation
// of QImage::QImage ( const uchar * data, int width, int height, Format format )
return dest;
}
cv::Mat utils::convertQImage2Mat(QImage &img_qt) {
cv::Mat tmp(img_qt.height(),img_qt.width(),CV_8UC3,(uchar*)img_qt.bits(),img_qt.bytesPerLine());
cv::Mat result; // deep copy just in case (my lack of knowledge with open cv)
cvtColor(tmp, result,CV_BGR2RGB);
return result;
}