Skip to content

Commit

Permalink
Merge PR #198 Incr frame size 640x480
Browse files Browse the repository at this point in the history
Increase frame size to 640x480
  • Loading branch information
felipe-m authored Jul 9, 2023
2 parents 58c2439 + 86b1126 commit 99d7d38
Show file tree
Hide file tree
Showing 26 changed files with 1,409 additions and 2 deletions.
6 changes: 6 additions & 0 deletions sim_fpga/tutorial/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ More info in its [tutorial 2 readme](./tut02)
In this example, instead of processing still images, the frames from the computer camera is processed by the _verilated_ color processing Verilog module.

More info in its [tutorial 3 readme](./tut03)

## [Tutorial 4](./tut04)

In this example, the video frame size has increased considerably, from 160x120 to 640x480. To test the performance with this size

More info in its [tutorial 4 readme](./tut04)
2 changes: 1 addition & 1 deletion sim_fpga/tutorial/tut03/rtl/color_proc.v
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module color_proc

// minimum number to consider an image detected and not being noise
// change this value
c_min_colorpixels = 128, // having 159744 pixels, 128 seems reasonable
c_min_colorpixels = 128, // having 13312 pixels, 128 seems reasonable

c_nb_buf_red = 4, // n bits for red in the buffer (memory)
c_nb_buf_green = 4, // n bits for green in the buffer (memory)
Expand Down
2 changes: 1 addition & 1 deletion sim_fpga/tutorial/tut03/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Authors:
// - Based on original version of David Lobato
// - Modified: Felipe Machado, https://github.com/felipe-m
// Tutorial 2:
// Tutorial 3:
// - includes centroid and proximity
// - the image is larger 160x120

Expand Down
64 changes: 64 additions & 0 deletions sim_fpga/tutorial/tut04/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
SIM_DIR := $(realpath $(dir $(MKFILE_PATH))/../..)
PROJECT_DIR := $(realpath $(SIM_DIR)/..)
IMGUI_DIR = $(PROJECT_DIR)/third_party/imgui
EXAMPLE_DIR = $(SIM_DIR)/tutorial/tut04
RTL_DIR = $(EXAMPLE_DIR)/rtl
INC_DIR = $(EXAMPLE_DIR)/include
SRC_DIR = $(EXAMPLE_DIR)/src
ASSETS_DIR := $(SRC_DIR)
SOURCES = $(SRC_DIR)/main.cpp
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
V_SOURCES = $(RTL_DIR)/color_proc.v
UNAME_S := $(shell uname -s)
LINUX_GL_LIBS = -lGL

CXXFLAGS = -I$(INC_DIR) -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -DASSETS_DIR=\\\"$(ASSETS_DIR)\\\" -g
LIBS =

##---------------------------------------------------------------------
## BUILD FLAGS PER PLATFORM
##---------------------------------------------------------------------

ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS += $(LINUX_GL_LIBS) -ldl `sdl2-config --libs` `pkg-config --libs opencv4`

CXXFLAGS += `sdl2-config --cflags` `pkg-config --cflags opencv4`
CFLAGS = $(CXXFLAGS)
endif

ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
LIBS += -L/usr/local/lib -L/opt/local/lib

CXXFLAGS += `sdl2-config --cflags`
CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS)
endif

ifeq ($(OS), Windows_NT)
ECHO_MESSAGE = "MinGW"
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`

CXXFLAGS += `pkg-config --cflags sdl2`
CFLAGS = $(CXXFLAGS)
endif

##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------

all: obj_dir/Vcolor_proc
@echo Build complete for $(ECHO_MESSAGE)

obj_dir/Vcolor_proc.h: $(V_SOURCES)
verilator --cc $(V_SOURCES) -x-assign unique --trace -CFLAGS "$(CXXFLAGS)" --exe $(SOURCES) -I$(RTL_DIR)

obj_dir/Vcolor_proc: obj_dir/Vcolor_proc.h $(SOURCES)
make -j 4 -C obj_dir/ -f Vcolor_proc.mk Vcolor_proc LIBS="$(LIBS)"

clean:
rm -rf obj_dir
16 changes: 16 additions & 0 deletions sim_fpga/tutorial/tut04/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Verilator+GUI Tutorial 4

This is the same as in Tutorial 3, but now taking a 640x480 image, to test if the processing is fast enough.
Now, each frame is 307,200 pixels, so it is an order of magnitude larger than in tutorial 3

The color processing is the same as in tutorial 3 and 2 (only changing some generics)

* [../../../phys_fpga/ulx3s/apio/ov7670x2_colorcentroid_160x120/color_proc.v](../../../phys_fpga/ulx3s/apio/ov7670x2_colorcentroid_160x120/color_proc.v)

The rest is the same as in tutorial 3.






Loading

0 comments on commit 99d7d38

Please sign in to comment.