0、在windows下有兩種仿真方式,第1種是在VS2015或更高版本下進行,第2種是在海思開發的Ruyistudio進行仿真。
1、在VS2015或更高版本下進行仿真:
參考:https://blog.csdn.net/avideointerfaces/article/details/90182987
工程名爲simulator_sample_vc14.sln,找不到的話用everything.exe搜索,雙擊用VS2017打開。
前兩個是功能性仿真,後兩個是指令性仿真。在功能性或指令性仿真內部又分爲使用opencv庫和不使用opencv庫兩種類型。它們的最終結果應該是一致的,但功能性驗證顯然速度要快很多(我仿真起來真沒看出多大的區別)。四個程序直接就能夠運行成功,運行結果如下,第一個是功能性仿真的輸出,第二個是指令性仿真的輸出:
如果你想要遷移到自己的模型和數據的話,則需要修改裏面的參數:
(1)更改得分閾值
(2)更改類別閾值等,如果你使用的是608大小的圖,還需要修改416->608, 13->19, 26->38, 52->76
(3)如果使用608大小的圖,還需要修改anchor,下圖是416對應的anchor,608的anchor網上一大堆可以找找
(4)換成自己的wk模型
(5)換成自己的圖片
注意這裏圖片是bbb...ggg...rrr...排列格式的,需要自己去生成,生成代碼見爲:
#include <opencv2/opencv.hpp>
#include <iostream>
#include <string>
#include <fstream>
#include <cstdio>
using namespace std;
using namespace cv;
int main()
{
int W = 416, H = 416, C = 3;
string inPath = R"(D:\soft\Hi3559A\HiSVP_PC_V1.1.2.0\software\data\detection\images\ref_yolov3\staff.jpg)";
Mat pic = imread(inPath);
resize(pic, pic, Size(416, 416));
int64 t1 = getTickCount();
int step = pic.step;
string outPath = R"(D:\soft\Hi3559A\HiSVP_PC_V1.1.2.0\software\sample_simulator\GetBGR\staff.bgr)";
remove(outPath.c_str());
ofstream outfile(outPath, std::ios::out | std::ios::binary | ios::app);
for (int k = 0; k < C; k++) {
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
outfile.write((char*)&pic.data[i*step + j * C + k], sizeof(uchar));
}
}
}
int64 t2 = getTickCount();
cout << "cost: " << (t2 - t1) * 1000 / getTickFrequency() << "ms" << endl;
outfile.close();
return 0;
}
最後再貼一下我運行自己數據的結果:
畫出來:
#include <opencv2/opencv.hpp>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
using namespace cv;
int main() {
//string path = R"(D:\soft\Hi3559A\HiSVP_PC_V1.1.2.0\software\data\detection\images\test\dog_bike_car.jpg)";
string path = R"(D:\soft\Hi3559A\HiSVP_PC_V1.1.2.0\software\data\detection\images\ref_yolov3\staff.jpg)";
Mat bgr = imread(path);
Mat a416;
resize(bgr, a416, Size(416, 416));
//rectangle(a416, Point(64.87,166.71), Point(174.98 , 383.54), Scalar(0, 0, 255), 2);
//rectangle(a416, Point(60.40, 92.48), Point(311.95, 311.59), Scalar(0, 0, 255), 2);
//rectangle(a416, Point(255.03, 59.72), Point(376.12, 121.87), Scalar(0, 0, 255), 2);
rectangle(a416, Point(220, 178), Point(253, 249), Scalar(0, 0, 255), 2);
rectangle(a416, Point(160, 178), Point(188, 235), Scalar(0, 0, 255), 2);
imshow("a416", a416);
waitKey(0);
return 0;
}
或者如果你使用了使用opencv庫的仿真,則直接在.\sample_simulator\sample_func_vc14\result_SVP_SAMPLE_YOLO_V3下就生成了圖片和結果的txt文件。
2、在Ruyistudio下進行仿真:
還沒有進行過。。。