Thanks for your reply!
Our code as below:
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include
#include “ObjectDetect.h”
#include “opencv2/core/core.hpp”
#include “opencv2/highgui/highgui.hpp”
#include “opencv2/imgproc/imgproc.hpp”
int main(int argc, char **argv)
{
//initialize object detection
char conPath[100] = “/home/nvidia/tools/models/obj.txt”;
HC::InitObjectDec(conPath);
//open camera
cv::VideoCapture cap(0);
if (!cap.isOpened()) {
std::cout << "Failed to open video: " << std::endl;
}
//set camera para
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);
//image from camera
cv::Mat img;
while (true)
{
//capture image
cap>>img;
//image for show
cv::Mat showIm = img.clone();
//calculate time
clock_t startT, endT;
startT = clock();
unsigned char* data_obj = (unsigned char*)img.data;
HC::object_info_obj tmpObj;
tmpObj.objectNum = 0;
//object detection
HC::ObjectDectect(data_obj, img.cols, img.rows, 2,(HC::object_info_obj*)(&tmpObj));
endT = (double)(1000 * (clock() - startT) / CLOCKS_PER_SEC);
std::cout << "Processing time : "<<endT<<"ms" << std::endl;
//draw image
char scoreStr[10] = "";
for (int i = 0; i<tmpObj.objectNum; i++)
{
std::string label;
cv::Rect tmpRt;
tmpRt.x = tmpObj.objectRts[i].x;
tmpRt.y = tmpObj.objectRts[i].y;
tmpRt.width = tmpObj.objectRts[i].width;
tmpRt.height = tmpObj.objectRts[i].height;
sprintf(scoreStr, "%f", tmpObj.confidence[i]);
cv::rectangle(showIm, tmpRt, cv::Scalar(0, 255, 205), 2, 4, 0);
cv::putText(showIm, scoreStr, cv::Point(tmpObj.objectRts[i].x,tmpObj.objectRts[i].y), 2, 0.5, cv::Scalar(255, 255));
}
//show image
imshow("result-1", showIm);
cv::waitKey(5);
}
HC::ObjectDectectFree();
system("pause");
getchar();
return 0;
}