Ask Your Question

Thread Safe

asked 2014-04-27 22:40:30 -0500

MRDaniel gravatar image


OpenCV is Thread Safe. How is this achieved deep down in the code? What patterns or techniques are used?



edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-04-28 14:55:44 -0500

GrumbleLion gravatar image

I've had a few thread glitches while using OpenCV.

The library itself is thread safe in that you can have multiple calls into the library at the same time, however the data is not always thread safe.

This means that if you have to pass a mat image between threads you have to use a mutex and call .CopyTo() to force a copy instead of a reference.

Note: Std::Vector is also not thread safe under all conditions as well.

edit flag offensive delete link more


Like he said, since OpenCV uses extensive internal use of the vector class, achieving thread safety is not always that easy ...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-04-29 04:18:08 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-04-27 22:40:30 -0500

Seen: 4,668 times

Last updated: Apr 28 '14