Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Windows doesn't run on the Rasp. But Linux (Raspbian) is simple...just get used to the fact that it's different than Windows. i find Linux much better adapted to development than Windows.

So to install opencv, just type at the command line:

sudo apt install libopencv-dev

You don't even need a complex IDE (anyway, it won't be fast on a Raspberry Pi). Create a file called Makefile near your cpp file:

CC = g++
SOURCES = main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE = MyProgram
CFLAGS = -c
CFLAGS += $(shell pkg-config opencv4  --cflags) 
LDFLAGS= $(shell pkg-config opencv4 --libs)

ifeq "$(CFG)" "Debug"
    CFLAGS += -Wall -O0 -g
        LDFLAGS += -g
else
    CFLAGS += -w -O3 -Ofast -std=c++11
        LDFLAGS += -s
endif

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
    @echo "\n***  Linking  ***"
    $(CC) $(OBJECTS) $(LDFLAGS) -o $(EXECUTABLE)

%.o: %.cpp
    @echo "\n***  Compiling" $< "  ***"
    $(CC) $(CFLAGS) -I$(INCLUDEDIRS) $< -o $@

clean:
    rm -rf *.o $(EXECUTABLE)

You might need to do some modifications according to your configuration.

Now, when you finished the development, just type: make. It will build your code.

If you ant a full-blown IDE, I suggest QT Creator. It's easy to configure for OpenCV.