merge with master
This commit is contained in:
+16
-9
@@ -23,6 +23,7 @@
|
|||||||
#define MAX_DETECT_SIZE 100
|
#define MAX_DETECT_SIZE 100
|
||||||
|
|
||||||
bool gRun;
|
bool gRun;
|
||||||
|
std::string obj_class[10]{"person", "car", "truck", "bus", "motor", "bike", "rider", "traffic light", "traffic sign", "train"};
|
||||||
|
|
||||||
cv::Mat frame_v;
|
cv::Mat frame_v;
|
||||||
cv::Mat frame_top_v;
|
cv::Mat frame_top_v;
|
||||||
@@ -205,24 +206,30 @@ int main(int argc, char *argv[])
|
|||||||
int x1 = b.x + b.w;
|
int x1 = b.x + b.w;
|
||||||
int y0 = b.y;
|
int y0 = b.y;
|
||||||
int y1 = b.y + b.h;
|
int y1 = b.y + b.h;
|
||||||
int obj_class = b.cl;
|
int objClass = b.cl;
|
||||||
|
std::string det_class = obj_class[b.cl];
|
||||||
|
float prob = b.prob;
|
||||||
|
|
||||||
cv::Scalar intensity = mask.at<uchar>(cv::Point(int(x0 + b.w / 2), y1));
|
cv::Scalar intensity = mask.at<uchar>(cv::Point(int(x0 + b.w / 2), y1));
|
||||||
|
|
||||||
if (intensity[0])
|
if (intensity[0])
|
||||||
{
|
{
|
||||||
|
|
||||||
if (obj_class == 0 /*person*/ || obj_class == 1 /*bicycle*/ || obj_class == 2 /*car*/
|
if (objClass < 6)
|
||||||
|| obj_class == 3 /*motorbike*/ || obj_class == 5 /*bus*/)
|
|
||||||
{
|
{
|
||||||
convert_coords(coords, coord_i, x0 + b.w / 2, y1, obj_class, H, adfGeoTransform, frame_nbr);
|
convert_coords(coords, coord_i, x0 + b.w / 2, y1, objClass, H, adfGeoTransform, frame_nbr);
|
||||||
coord_i++;
|
coord_i++;
|
||||||
|
|
||||||
|
//std::cout<<objClass<<" ("<<prob<<"): "<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<"\n";
|
||||||
|
cv::rectangle(frame, cv::Point(x0, y0), cv::Point(x1, y1), yolo.colors[objClass], 2);
|
||||||
|
// draw label
|
||||||
|
int baseline = 0;
|
||||||
|
float fontScale = 0.5;
|
||||||
|
int thickness = 2;
|
||||||
|
cv::Size textSize = getTextSize(det_class, cv::FONT_HERSHEY_SIMPLEX, fontScale, thickness, &baseline);
|
||||||
|
cv::rectangle(frame, cv::Point(x0, y0), cv::Point((x0 + textSize.width - 2), (y0 - textSize.height - 2)), yolo.colors[b.cl], -1);
|
||||||
|
cv::putText(frame, det_class, cv::Point(x0, (y0 - (baseline / 2))), cv::FONT_HERSHEY_SIMPLEX, fontScale, cv::Scalar(255, 255, 255), thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
float prob = b.prob;
|
|
||||||
|
|
||||||
//std::cout<<obj_class<<" ("<<prob<<"): "<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<"\n";
|
|
||||||
cv::rectangle(frame, cv::Point(x0, y0), cv::Point(x1, y1), yolo.colors[obj_class], 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ public:
|
|||||||
dataDim_t input_dim;
|
dataDim_t input_dim;
|
||||||
dataDim_t getOutputDim();
|
dataDim_t getOutputDim();
|
||||||
|
|
||||||
bool fp16;
|
bool fp16, dla;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|||||||
+9
-1
@@ -24,12 +24,20 @@ Network::Network(dataDim_t input_dim) {
|
|||||||
num_layers = 0;
|
num_layers = 0;
|
||||||
|
|
||||||
fp16 = false;
|
fp16 = false;
|
||||||
if(const char* env_p = std::getenv("TKDNN_MODE"))
|
dla = false;
|
||||||
|
if(const char* env_p = std::getenv("TKDNN_MODE")) {
|
||||||
if(strcmp(env_p, "FP16") == 0)
|
if(strcmp(env_p, "FP16") == 0)
|
||||||
fp16 = true;
|
fp16 = true;
|
||||||
|
else if(strcmp(env_p, "DLA") == 0) {
|
||||||
|
dla = true;
|
||||||
|
fp16 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(fp16)
|
if(fp16)
|
||||||
std::cout<<COL_REDB<<"!! FP16 INERENCE ENABLED !!"<<COL_END<<"\n";
|
std::cout<<COL_REDB<<"!! FP16 INERENCE ENABLED !!"<<COL_END<<"\n";
|
||||||
|
if(dla)
|
||||||
|
std::cout<<COL_GREENB<<"!! DLA INERENCE ENABLED !!"<<COL_END<<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
Network::~Network() {
|
Network::~Network() {
|
||||||
|
|||||||
+10
-1
@@ -51,7 +51,16 @@ NetworkRT::NetworkRT(Network *net, const char *name) {
|
|||||||
dtRT = DataType::kHALF;
|
dtRT = DataType::kHALF;
|
||||||
builderRT->setHalf2Mode(true);
|
builderRT->setHalf2Mode(true);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
if(net->dla && builderRT->getNbDLACores() > 0) {
|
||||||
|
dtRT = DataType::kHALF;
|
||||||
|
builderRT->setFp16Mode(true);
|
||||||
|
builderRT->allowGPUFallback(true);
|
||||||
|
builderRT->setDefaultDeviceType(DeviceType::kDLA);
|
||||||
|
builderRT->setDLACore(0);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//add input layer
|
//add input layer
|
||||||
ITensor *input = networkRT->addInput("data", DataType::kFLOAT,
|
ITensor *input = networkRT->addInput("data", DataType::kFLOAT,
|
||||||
DimsCHW{ dim.c, dim.h, dim.w});
|
DimsCHW{ dim.c, dim.h, dim.w});
|
||||||
|
|||||||
Reference in New Issue
Block a user