|
|
|
@ -25,17 +25,15 @@ static std::vector<std::string> classes;
|
|
|
|
|
bool AlgJd::init(QString path_model, QString path_jpg)
|
|
|
|
|
{
|
|
|
|
|
// Load names of classes
|
|
|
|
|
std::string classesFile = "D:/model/jd.names";
|
|
|
|
|
|
|
|
|
|
std::string classesFile = "../model/jd.names";
|
|
|
|
|
// Give the configuration and weight files for the model
|
|
|
|
|
cv::String modelConfiguration = "D:/model/jd.cfg";
|
|
|
|
|
cv::String modelWeights;
|
|
|
|
|
cv::String modelConfiguration = "../model/jd.cfg";
|
|
|
|
|
cv::String modelWeights = "../model/jd.weights";
|
|
|
|
|
|
|
|
|
|
if (path_model.length() > 0) {
|
|
|
|
|
modelWeights = path_model.toStdString();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
modelWeights = "D:/model/jd.weights";
|
|
|
|
|
classesFile = path_model.toStdString() + "/jd.names";
|
|
|
|
|
modelConfiguration = path_model.toStdString() + "/jd.cfg";
|
|
|
|
|
modelWeights = path_model.toStdString() + "/jd.weights";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ifstream classNamesFile(classesFile.c_str());
|
|
|
|
@ -54,15 +52,16 @@ bool AlgJd::init(QString path_model, QString path_jpg)
|
|
|
|
|
|
|
|
|
|
net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA);
|
|
|
|
|
net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//cv::Mat image = cv::imread("alg_jd.jpg");
|
|
|
|
|
cv::Mat image;
|
|
|
|
|
if (path_jpg.length() > 0) {
|
|
|
|
|
image = cv::imread(path_jpg.toStdString());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
image = cv::imread("D:/Release/alg_jd.bmp");
|
|
|
|
|
image = cv::imread("alg_jd.bmp");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//识别一张图,测试模型是否正确,并且完成GPU数据加载
|
|
|
|
|
if (!image.data) return false; //判断测试图片是否正常读取
|
|
|
|
|
std::vector<std::pair<int, cv::Rect> > results;
|
|
|
|
|