After a few days of learning OpenCV, I started to write my first OpenCV program, the requirement is to detect single color and find three largest color objects, it’s a very basic program, but you can know a lot about computer vision if you understand the code. OpenCV provide so many functions, you have to know what you want and what the function does.
This program still run on the Raspberry Pi, frame per second is about 8.5, if you want to find more or less than 3 biggest objects, you can change N. Here is code(You also can get it in my Github) sg_color.c:
Here is makefile:
LIBS= `pkg-config --libs opencv` CFLAGS= `pkg-config --cflags opencv` objects= sg_color.o sg_color: $(objects) gcc $(LIBS)$(CFLAGS) -o sg_color $(objects) .PHONY: clean clean: rm sg_color $(objects)