
OpenCV 4.0 - conductor
https://opencv.org/opencv-4-0-0.html
======
ChuckMcM
Pretty amazing piece of code, the loss of the C API is sad since a number of
embedded systems started there and are skittish about going to C++11. I used
version 3 to build a simple license plate reader that I had stuck in an
upstairs window for a time. Combine that with the simple IMSI catcher that was
referenced here a while ago and you've got your own little neighborhood watch
station with some pretty grown up capabilities.

~~~
coder543
> the loss of the C API is sad

From the article: "A lot of C API from OpenCV 1.x has been removed."

That doesn't _sound_ like they removed all of the C APIs, unless the only C
API was the one that came with 1.x? I'm not very familiar with OpenCV, but
since they homepage still talks about offering Python and Java APIs, it seems
likely that they're going through a C interop layer somewhere. Did they never
introduce new C APIs in the last three major versions?

If there really is no C API, that's sad and kinda limiting. Everything binds
to C, but almost nothing can bind to C++.

> a number of embedded systems started there and are skittish about going to
> C++11

I'm curious to know what embedded systems are powerful enough to do real-time
computer vision, but don't support a C++11 toolchain? C++11 is pretty old at
this point, and between gcc and clang, almost everything with a 32-bit or
better processor is probably supported, as well as probably many 8-bit and
16-bit architectures, but I'm skeptical about how much CV you can do on the
kind of processors that are built as 16-bit processors.

~~~
ChuckMcM
It isn't a question of power, I use a lot of Cortex M machines (32 bit ARM)
which can compile C++11 just fine, it is that there is a lot of infrastructure
(like you really have to have a working heap system, startup files that know
how to build the necessary infrastructure, Etc.) that is intimidating to
embedded programmers. Not to mention screwing up the symbol names :-).

~~~
coder543
mbed makes it pretty easy to get going with C++ on Cortex-M, last time I tried
it, but that was over a year ago.

Still, I'm skeptical about how much CV you could actually do on a Cortex-M
processor. A few dozen to a few hundred kilobytes of RAM is really limiting
when we're talking about just loading up an image from a camera, let alone
doing computer vision on that image, unless you pay for a Cortex-M7 to get 1MB
of RAM or something really expensive like that... at which point, an entire
Raspberry Pi 0 SBC with 512MB of RAM is actually cheaper than just your
microcontroller alone.

Of course, the microcontroller boots up instantly and supports incredibly
useful sleep modes and a variety of other peripherals... but for raw
performance per dollar, the M7s are just so costly.

~~~
ChuckMcM
> Still, I'm skeptical about how much CV you could actually do on a Cortex-M
> processor.

You have seen OpenMV right? ([https://openmv.io](https://openmv.io)) I've got
one of their early cameras (waiting on my H7's).

~~~
coder543
Ah, a Cortex-M7 with 1MB of RAM... just like I mentioned. haha, the earlier
editions used an M4 with 256KB of RAM it looks like, but yeah.

Do you think you could run the license plate reader you wrote earlier on one
of these? What are the advantages you see for this over a Raspberry Pi 0 with
a Raspberry Camera module? Or the new, powerful Raspberry Pi 3A+ with a camera
module? This is certainly more expensive than either Pi option, with a lower
resolution camera.

~~~
ChuckMcM
I'm reasonably certain it can be run on the H7 but not sure about the H4. It
is one of my test cases :-). Note that these chips also include a DDR memory
controller so you can put 16MB of RAM on them pretty simply, some of ST
Micro's 'Discovery' cards come with this populated, but that is not used on
the H4 or H7 camera.

------
Iv
Oh! G-API seems nice! It looks like something I had to implement imperfectly
at one point (and I suspect many OpenCV developer also did it). The ability to
describe a pipeline and having it run automatically it really a good thing to
have.

~~~
lovelearning
You might also find Halide[1] interesting then. It too is a computation graph
that does a good job of separating core algorithm and optimizations.

OpenCV's neural networks module actually uses Halide as an optional backend. I
found it to be a practical approach to run TF/Torch/Caffe/Darknet models on
CPUs and OpenCL/AMD.

There was an OpenCV proposal to port _all_ algorithms to Halide API [1]. I
think that's still the long term plan, and G-API is a kind of stopgap till
then [2].

[1]: [http://halide-lang.org/](http://halide-lang.org/)

[2]: [https://github.com/opencv/opencv/wiki/OE-23.-Module-
GAPI](https://github.com/opencv/opencv/wiki/OE-23.-Module-GAPI)

~~~
Iv
Interesting, thanks!

------
chunsj
Oh, it seems that OpenCV 4.0 does not support more easy to use/bind C API.
Sad.

~~~
nebgnahz
Yes, it is sad. OpenCV has a code-gen for Java/Python but they are hard to
work with. A number of projects in other programming languages (Rust [1], Go
[2]) has to use custom build wrappers.

[1] [https://github.com/nebgnahz/cv-rs](https://github.com/nebgnahz/cv-rs) [2]
[https://github.com/hybridgroup/gocv](https://github.com/hybridgroup/gocv)

------
kartickv
As an iOS engineer, I remember reading that OpenCV is a few TIMES slower than
alternatives like Core Image.

I wish OpenCV made use of the GPU and vector hardware on phones. Is there an
alternative to OpenCV that does?

~~~
turowicz
It does use gpu, you need to compile it with a flag.

~~~
kartickv
Oh, which one? I was under the impression it uses only Nvidia GPUs (CUDA) on
desktop.

~~~
Benjamin_Dobell
There are a _heap_ of CMake flags that turn on various features e.g. CUDA:

[https://github.com/opencv/opencv/blob/4.0.0/CMakeLists.txt#L...](https://github.com/opencv/opencv/blob/4.0.0/CMakeLists.txt#L227)

but also OpenCL:

[https://github.com/opencv/opencv/blob/4.0.0/CMakeLists.txt#L...](https://github.com/opencv/opencv/blob/4.0.0/CMakeLists.txt#L267)

and Vulkan (which was only merged around a month ago):

[https://github.com/opencv/opencv/blob/4.0.0/CMakeLists.txt#L...](https://github.com/opencv/opencv/blob/4.0.0/CMakeLists.txt#L239)

Perhaps that last one works on mobile, although I wouldn't get your hopes up.

I haven't really used OpenCV since 2.4.x, however assuming the same holds
true, performance enhancements are on a feature by feature basis. Meaning that
if you enable CUDA etc. then it's not going to work for everything. Not GPU,
but a common compile time enhancement (at least it used to be) was to compile
with Intel TBB (thread building blocks) as a lot of the APIs included
optimisations.

~~~
kartickv
Thanks, but iOS supports neither CUDA, OpenCL, Vulkan nor TBB. It's only Metal
and higher-level frameworks like Core Image for GPU, and vImage for SIMD image
manipulation.

~~~
Benjamin_Dobell
You can use MoltenVK to run Vulkan via Metal
([https://github.com/KhronosGroup/MoltenVK](https://github.com/KhronosGroup/MoltenVK)).
Apparently performance is quite good for regular 3D rendering, compute support
is officially listed, but I'm not at all sure what performance is like.

------
barbwire
Anyone who can understand what OpenCV actually is from their front page is
doing better than me.

~~~
cjhanks
OpenCV is ubiquitous in some domains. It's like asking; "What's numpy?"

~~~
virtualized
What's numpy?

~~~
topspin
Portmanteau of Numeric and Python. It's widely used Python library for matrix
math and functions for operating on large arrays and matrices.

