
Introducing ccv, a modern computer vision library - liuliu
http://libccv.org/post/introducing-ccv-milestone/
======
asdfaoeu
Had to do (to build on ubuntu 12.04)

    
    
        sudo apt-get install clang libjpeg-dev libpng-dev libfftw3-dev libgsl0-dev libblas-dev liblinear-dev libblas-dev
        cd bin/
        make

Then add -lgslcblas to lib/.LN and run again, make

~~~
liuliu
At minimal, it should be able to build without any dependencies (drop the code
into your XCode project, and it will run). But to use command line tools in
./bin, you need libjpeg and libpng indeed.

libgsl and liblinear are required for all the training programs (bbfcreate,
dpmcreate). libfftw3 can help with dpmdetect performance.

------
the_cat_kittles
Nice work, from what i can tell! How does this compare to open cv? Are there
python bindings in the works yet? Congrats!

------
yuvadam
Hmm. What's the main motivation to use libccv as opposed to OpenCV?

~~~
timb
<http://libccv.org/post/an-elephant-in-the-room/>

~~~
liuliu
Personally, I am a little frustrated by OpenCV's move to C++ interface. Yes,
it looks like a high-level language by mimicking Matlab style. But at the end
of the day, the implementation uses many advanced C++ features, and ignored
one thing that C++ is really good at: abstracting to objects / object
interactions.

Computer vision task is very different, from, for example, a game engine. From
engineering perspective, computer vision tasks are very functional. You throw
an image to it, get some semantic information out of it, and done. The only
objects there are images, and it is boring (Really? You need a inheritance
relationship between different _type_ of images? Tell me what's the behavioral
difference!). Thus, object-oriented style is not the best abstraction for this
kind of task at all. However, C++ is all about object-oriented programming!
(and it is really useful for game engines, where you actually have a lot
different objects and interacting with each other).

(Then here is the question, how to support different types of image? From the
people I talked with, it seems to me the general conscious is to use generated
code no matter you use c or c++. Generated code can be type safe, and still
very fast. Effectively, this is what template does for OpenCV and macro does
for ccv, although, both approaches are not the best.)

Take the end result, it is easy to use OpenCV's new interface (if you are
familiar with Matlab), but hard to hack in. OTOH, it does provide quite a lot
algorithms for you to experiment with, but then, if you need to write
something new (the end goal of experimentation after all), it is really not an
easy undertaking.

ccv takes a different path. Don't experiment with it, use it in your
application, trust the underlying implementation is the best-of-its-kind, and
you will be happy.

~~~
repsilat
> However, C++ is all about object-oriented programming!

That really depends on how you use the language. Looking at the code I
normally see there's almost no inheritance, but lots of static polymorphism
through templates. Data tends to be stored in structs, tuples and the default
data structures (vectors, mostly), and a lot of use is made of the new lambdas
and the functional bits of the STL.

I know that you can write Java in C++ (and that many people do), but it's not
really the language's raison d'être.

------
PopaL
Nice work, but you need to add a license for the library, if you want people
to start using and improving your library.

~~~
rmc
+1 more software should say what the copyright is.

On their github page, COPYING has a licence (
<https://github.com/liuliu/ccv/blob/unstable/COPYING> ). Looks BSDlike

------
yes_but_also
What about the SIFT and SWT patents?

~~~
pm90
A bit off-topic: a prof. at the Uni once told me that David Lowe (who invented
SIFT) never got any money from the patent (which I think belongs jointly to
him and UBC) because commercial implementations would make a few changes to
the algo and just use it, without citation or license. If any HN'ers know more
about this, I would be glad to hear it

~~~
jjwiseman
While it does seem to be regarded to be easy to avoid infringing on the SIFT
patent by changing the algorithm in a minor way (e.g. using SURF features but
doing SIFT-style search), I know there are companies that have licensed SIFT
from Lowe, and I would expect he's been paid for those licenses.

------
oulipo
Check Megawave for another great C library with excellent and quality algos!

<http://megawave.cmla.ens-cachan.fr/>

the library design is a bit dated but the code contributions are outstanding!

~~~
oulipo
Also, I think the way forward is something like scikit.image (python library)
with a way to add C-coded algorithms

~~~
lvh
Doesn't scikit already have an obvious way to add C code? It's Python. There's
Cython/raw CPython API if you don't care about compatibility with alternative
implementations, and ctypes (shudder) if you do.

~~~
JoachimSchipper
Way off-topic, but are you saying that ctypes is _less_ pleasant than the
CPython API? My experience with the latter wasn't all that pleasant...

------
jasonwatkinspdx
The radix tree caching mechanism is interesting, and seems very general. I'm
new to techniques of randomized algorithm analysis, so I can't whip up a
perspective of my own yet.

Does anyone else recognize this? Has it been rigorously treated? Seems like a
similar approach to more applications in general using bagwell tries would be
useful for both scala and clojure.

------
dpsatch
Check also <http://www.vlfeat.org/>.

It is quite used in the research community, with new algorithms coming soon
(check this: [http://eccv2012.unifi.it/program/tutorials/modern-
features-a...](http://eccv2012.unifi.it/program/tutorials/modern-features-
advances-applications-and-software/)).

~~~
liuliu
I admire their work, [http://libccv.org/post/call-for-a-new-lightweight-c-
based-co...](http://libccv.org/post/call-for-a-new-lightweight-c-based-
computer-vision-library/)

Their documentation is very nice, and back then when I implementing linear
MSER for OpenCV, I learned a lot from their semilinear MSER implementation.

But, I never understand why they want to mimick object-oriented interface in
their implementation. Especially, their abstraction strikes me as "weird".
Each algorithm implementation is an "object" to encapsulate some intermediate
data, or to retain some parameter settings? It is a far stretch to what these
computer vision algorithm does.

In my mind, computer vision algorithms are functions, which takes image/image
sequence in, and emit semantic information out. Reusable intermediate data
should be implementation detail, it shouldn't overshadow how the interface
looks like.

Sorry if I am acting too opinionated on this topic, I am too passionate about
good interface design.

~~~
dpsatch
In vlfeat there is a strong focus on the algorithms, since it is mainly
developed by a researcher for his own research. This is the reason of the
"weird" object-oriented interface.

Keeping the "status" of the algorithm in an object gives the following
advantages:

\- The interface encourages cleaner code: computer vision algorithms often
come with many parameters. One has to use his own data structure, or many
variables or constants to keep them in memory, and then call a function with a
very long signature. This produces not so clean code, and the long signature
could lead to mistakes in the parameter values. Using an object with get/set
functions make easier to define in an iterative manner the parameters and call
the function in a clean an less error-prone way.

\- Many computer vision algorithms are iterative. For this kind of algorithms,
having an object representing the status of the algorithms allows to
stop/restart/continue it easily. The possibility to check the convergence of
certain algorithms is vital in computer vision (SVMs for example).

You are right when you say that implementation details shouldn't interfere
with the interfaces. But vlfeat doesn't have a general "extractFeatures"
function, it implement different famous algorithms. So it makes sense to
assume that if one uses SIFT, have a basic knowledge of how it works and
prefers to exploit it at its best (in the documentation you can find basic
information of any algorithm anyway).

So I think the two library are different, libccv focus on those developers
that want to use computer vision algorithms without a deep knowledge of them,
while vlfeat requires the developer to have a proper computer vision
knowledge, but gives more power to him.

------
javajosh
Nice job liuliu. Being new to CV, I have what is probably a stupid question: I
see that you do text detection, but what then? Does your library have the
ability to do OCR on the text? And if not, what is your recommended way to do
OCR on the text?

~~~
liuliu
No, ccv doesn't do OCR. Tesseract: <https://code.google.com/p/tesseract-ocr/>

~~~
javajosh
Thanks! That looks like just the ticket. Do you have any tips for efficiently
combining your library with Tesseract?

------
harigov
OpenCV is intended to be useful for computer vision researchers to test new
functionality easily and also for developers to put together CV based
functionality easily. I think the new C++ interface is pretty neat. Although I
do agree that it is becoming humongous, that is a sign of maturity rather than
neglect. As a computer vision developer, I believe that choice of algorithms,
and ability to use low level functionality is key to developing robust
computer vision applications. Mostly because there is no one size fits all.
Probably you are aiming for fewer use cases than what is possible with OpenCV.
In that case, it makes sense.

------
mercuryrising
Just thought you might like to know that there is another project with the
same name. (<http://ccv.nuigroup.com/>). Although they seem to stylize it with
all caps.

Cool though, looks good.

------
godisdad
I just started reading the OpenCV book this week. Eerily apropos.

Suggestion for liuliu: list supported platforms in your Readme - it may save
you some email. And it seems you're targeting Macs from all the Xcode
comments.

------
thechut
Could this be adapted to run on arduino? Or does it require too many libs?

~~~
ballooney
I suspect it requires too much everything (cpu, ram, io speed), by several
orders of magnitude, to run on an arduino.

If you're seriously asking, and this isn't some kind of internet meme/joke I'm
not familiar with, you might find it interesting and instructive to have a
look at the datasheet of the AtMega328[1], the chip an Arduino Uno uses, and
compare it to, say, what you might find in a typical intel desktop machine.

Just as one crude scalar comparison to illustrate the sort of differences, the
atmega328 doesn't have the ability to do floating point operations in hardware
, so you have to emulate them in software using the core's fixed point
hardware (the toolchain will do this for you). This means potentially hundreds
of cpu cycles per floating point operation. In the past i have managed to get
an atmega328, at 16Mhz, to perform about 60,000 floating point multiplications
per second. According to the wikipedia[2], a 2010 Intel Core i7 cpu can do
about 109 billion floating point operations per second. That's nearly 2
millions times the speed!

If you want something of arduino size and arduino price, that will let you
play with machine vision, the Raspberry Pi might be far more useful to you.

Finally, I'm not saying you _can't_ do CV on an 8-bit embedded micro, I have
done some in the past myself, but it's a very different and far more limited
beast to what most people would understand as modern CV and required in my
case an great deal of hand optimisation and gory bit-hacks.

[1] <http://www.atmel.com/devices/atmega328.aspx> [2]
<http://en.wikipedia.org/wiki/FLOPS> [3] <http://www.raspberrypi.org/>

~~~
thechut
Thanks for your response, and no it was not a troll but a serious (albeit
naive) question. Thank you for answering my question with good references and
very respectfully. I actually do know a fair amount about Arduino and I should
have put it together that the 328 wouldn't be anywhere near fast enough. I'm
sure it would be pretty easy to run it on a Raspberry Pi and I have been
clamoring to get my hands on a RasPi but am still in the preorder queue :/

But Arduino also has the upcoming Arduino Due which is based on a 32bit ARM
Cortex M3, which still may be powerful enough. I guess I would revise my
question to be would it be possible to get this (or something similar) running
in the Arduino Environment, regardless of speed (without a full OS stack)?

~~~
simcop2387
looking at the specs for it, there might still be an issue of ram, since the
ATSAM3X8E has only 100kb of ram. if you limit what you do you can likely get
some form of it working but to be honest i'm not sure how limited that would
be at the moment. You'd certainly have to lower the resolution to something
like 160x120, since even 320x240 would take up 192kb of ram in raw rgb. so
limited resolution, possibly even doing it in yuv with 4:2:0 like it's a low
quality jpeg would probably be possible, but you would end up having some
things more difficult to work with e.g. find the _red_ ball. speed wise at
84-85mhz it ought to be good enough to do the processing at a few frames per
second which for lots of things would likely be good enough.

all of this is just speculation based off of what i found googling the chip on
it, and then the libccv might not even fit on the 512kb flash it has for the
program you put on it.

my thought would be, bight the bullet and go with a raspberry pi or something
like that for doing image processing, faster cpu, more ram, and you could hook
it up to something like the arduino due, to do other logic, and have the due
ask it questions like, "where is the ball" etc.

source: [http://www.linkedin.com/groups/Arduino-Due-featuring-
Atmel-A...](http://www.linkedin.com/groups/Arduino-Due-featuring-Atmel-
ATSAM3X8E-1268377.S.118786784?qid=a35402e3-76b7-48df-
ac40-3ce85e5e08e9&trk=group_most_popular_guest-0-b-ttl&goback=.gmp_1268377)

------
geon
Are there any video demonstrations? I found nothing good on youtube.

------
lordmatty
Any thoughts about putting this on a smartphone?

~~~
liuliu
It compiles with you iOS XCode project (drop the source code in and it will
compile).

------
tibbon
I need to sit down and read the docs better, but is there any easy(ish) way
for me to use this with Ruby/Rails?

~~~
jomo
I would also be greatly interested in this, as well as an explicit license to
see how viable this is as an option.

------
antsam
I probably missed it but how do you train more faces with your library?

~~~
liuliu
It is face detection (outline faces from images), not face recognition (tell
whom the face belongs to). To train your own face detector, follow
instructions here:

<http://libccv.org/doc/doc-bbf/#how-to-train-my-own-detector>

------
swalsh
It's nice to see some competition with Open CV

~~~
excuse-me
There is cimg <http://cimg.sourceforge.net/>

------
tintor
Nice job!

