Live data from Hacker News

Imgdiff: Faster than the fastest pixel-by-pixel image difference tool

github.com

61–66 of 66 posts

Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool

#61

Earlier quoted context omitted.

Regarding [1], many OpenCV functions in Python support an optional dst argument, similar to how they do in the C++ API. This makes the memory management situation not completely hopeless. In my experience, the only drawback of the Python API is the fact that it cannot utilize the multithreading module (probably does not release the GIL for long calls).

I believe many (most?) opencv & numpy operations release the GIL. Good point about OpenCV's in-place operations. Sometimes it's tricky/impossible to do that in numpy if you need to implement something that OpenCV doesn't provide. For example the C code that I linked in my previous comment, we wrote as an optimization of OpenCV's `matchTemplate` when the inputs meet a specific condition (that both input images are the…

That's a nice and tidy codebase, real pleasure to read.

> I believe many (most?) opencv & numpy operations release the GIL.

Any idea how I can determine this? I am prototyping a real time machine vision application targeting 2x720p@240fps and I want to avoid writing any C++ for as long as possible.

Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool

#62

Earlier quoted context omitted.

I believe many (most?) opencv & numpy operations release the GIL. Good point about OpenCV's in-place operations. Sometimes it's tricky/impossible to do that in numpy if you need to implement something that OpenCV doesn't provide. For example the C code that I linked in my previous comment, we wrote as an optimization of OpenCV's `matchTemplate` when the inputs meet a specific condition (that both input images are the…

That's a nice and tidy codebase, real pleasure to read. > I believe many (most?) opencv & numpy operations release the GIL. Any idea how I can determine this? I am prototyping a real time machine vision application targeting 2x720p@240fps and I want to avoid writing any C++ for as long as possible.

I don't know much about Python's C API, but this is the line in the OpenCV Python bindings that drops the GIL: https://github.com/opencv/opencv/blob/4.5.0/modules/python/s...

(see https://docs.python.org/3/c-api/init.html#releasing-the-gil-... in the Python C API manual).

That's only called from the ERRWRAP2 macro here: https://github.com/opencv/opencv/blob/4.5.0/modules/python/s...

That macro, in turn, is called from gen_template_func_body in gen2.py: https://github.com/opencv/opencv/blob/4.5.0/modules/python/s...

And that seems to be a code generator that is generating the bindings for all the OpenCV functions: https://github.com/opencv/opencv/blob/4.5.0/modules/python/s...

As to testing this, on Linux I'd run `atop` to see if your program is using all available CPUs.

Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool

#63

Earlier quoted context omitted.

That's a nice and tidy codebase, real pleasure to read. > I believe many (most?) opencv & numpy operations release the GIL. Any idea how I can determine this? I am prototyping a real time machine vision application targeting 2x720p@240fps and I want to avoid writing any C++ for as long as possible.

I don't know much about Python's C API, but this is the line in the OpenCV Python bindings that drops the GIL: https://github.com/opencv/opencv/blob/4.5.0/modules/python/s... (see https://docs.python.org/3/c-api/init.html#releasing-the-gil-... in the Python C API manual). That's only called from the ERRWRAP2 macro here: https://github.com/opencv/opencv/blob/4.5.0/modules/python/s... That macro, in turn, is called fro…

Nice spelunking! If there is hope of avoiding C++ altogether, then I'll try testing it again on something beefier than my laptop. Thanks for taking the time and effort.

Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool

#66
post #50

Earlier quoted context omitted.

Citation needed? I know things have been announced but what's available now?

GPUDirect has been available for quite sometime now: https://developer.nvidia.com/gpudirect

Thanks! I forgot storage was supported by that.
Post reply on HN