Ask Your Question
1

Thread Safe

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

MRDaniel gravatar image

Hello.

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

Regards,

Daniel

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

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

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

Comments

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 -0600 )edit

Question Tools

Stats

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

Seen: 10,842 times

Last updated: Apr 28 '14