Is Opencv dnn module thread-safe

asked 2017-08-31 05:19:06 -0500

chibai gravatar image

I want to deploy an image classification application with opencv dnn module. here's some logic code:

inputBlob = cv::dnn::blobFromImage(img); 
this->caffeNet.setInput(inputBlob, "data");
probMat = this->caffeNet.forward("prob").reshape(1, 1); 
cv::minMaxLoc(probMat, NULL, NULL, NULL, &classNumber);

if it's not thread-safe, where should I add lock?? like this?

mtx.lock();
probMat = this->caffeNet.forward("prob").reshape(1, 1); 
mtx.unlock();
edit retag flag offensive close merge delete