I use tensorRT5 to test multithread support.I use the thread1 function ,it can be worked.But when I put function thread1 to thread and run thread_test function, the program break.
void ThreadTest::thread_test() {
_thread1 = new std::thread(&ThreadTest::thread1, this);
}
void ThreadTest::thread1() {
ASSD* detector = new ASSD("../model");
cv::VideoCapture cap("../data/test.mp4");
cv::Mat image;
int count = 0;
while (count<10000) {
cap >> image;
std::vector<BBoxInfo > outputBBoxes;
std::chrono::time_point<std::chrono::system_clock> t1 = std::chrono::system_clock::now();
//inference the image
detector->detect(image, outputBBoxes);
std::chrono::time_point<std::chrono::system_clock> t2 = std::chrono::system_clock::now();
float dur = (float)std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1).count() / 1000;
std::cout << "2222222222ASSD time:" << dur << "ms" << std::endl;
for (int i = 0; i < outputBBoxes.size(); i++) {
BBoxInfo facebox = outputBBoxes[i];
cv::Rect box = cv::Rect(facebox.x1, facebox.y1, facebox.x2 - facebox.x1, facebox.y2 - facebox.y1);
cv::rectangle(image, box, cv::Scalar(255, 0, 0), 2);
}
cv::namedWindow("test111", CV_WINDOW_NORMAL);
cv::imshow("test111", image);
cv::waitKey(1);
count++;
}
}