Skip to content

Commit

Permalink
SO MANY IMPROVEMENTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Richter authored and Sam Richter committed Nov 24, 2021
1 parent ab23040 commit a443be1
Show file tree
Hide file tree
Showing 54 changed files with 647 additions and 27,378 deletions.
39 changes: 39 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "D:\\Applications\\VisualStudio\\VC\\Tools\\MSVC\\14.29.30133\\bin\\Hostx64\\x64\\cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
},
{
"name": "ARM",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"__linux__",
"__unix__"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "D:\\Programs\\Raspbian10-Windows64-Toolchain-8.3.0\\raspbian10\\bin\\arm-raspbian10-linux-gnueabihf-g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-arm"
}
],
"version": 4
}
11 changes: 9 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"xstddef": "cpp",
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
"xutility": "cpp",
"*.tcc": "cpp",
"cstdarg": "cpp",
"cwctype": "cpp",
"memory_resource": "cpp",
"string_view": "cpp",
"cinttypes": "cpp"
},
"cmake.configureOnOpen": false
}
Binary file modified bin/vision_program
Binary file not shown.
30 changes: 21 additions & 9 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
# -l{libname} -> link with {libname} - remember that libraries all start with 'lib' then end in an extention - {libname} only refers to the name between those - ex. libLIBRARY.so -> -lLIBRARY
# -L{path} -> add a path in which to search for specified libs (-l's, see above)
# -Wl,{option} -> pass an option to the linker (this is only here because it was used in the source Makefile)
# -mcpu/mfpu -> architecture/feature options(for using NEON): https://gist.github.com/fm4dd/c663217935dc17f0fc73c9c81b0aa845

#rwildcard = $(foreach d,$(wildcard $(addsuffix *,$(1))),$(call rwildcard,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d)))
rwildcard = $(foreach d,$(wildcard $(addsuffix *,$(1))),$(call rwildcard,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d)))

mode ?= windows-release

Expand All @@ -26,13 +27,11 @@ SRC_DIR := src
OBJ_DIR := obj
BIN_DIR := bin

#SRC_EXT := cpp c s S

PROGRAM := $(BIN_DIR)/vision_program
#SRC := $(wildcard $(SRC_DIR)/*.cpp)
SRC_T := $(wildcard $(SRC_DIR)/*.cpp) $(wildcard $(SRC_DIR)/extras/*.cpp)
#SRC_R := $(wildcard $(SRC_DIR)/*.cpp) $(wildcard $(SRC_DIR)/**/*.cpp)
#SRC_R := $(call rwildcard,$(SRC_DIR)/,*.cpp)
SRCS := $(SRC_T)
OBJS := $(SRCS:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
SRCS := $(call rwildcard,$(SRC_DIR)/,*.cpp *.c *.S *.s)
OBJS := $(SRCS:$(SRC_DIR)/%=$(OBJ_DIR)/%.o)

CDEBUG := -g -Og
LDEBUG := -g
Expand All @@ -41,8 +40,12 @@ LRELEASE :=

CPPFLAGS := -pthread -Iinclude -Iinclude/opencv -MMD -MP
CFLAGS := -Wall
ASMFLAGS := -mcpu=cortex-a72 -mfpu=neon-fp-armv8
LDFLAGS := -pthread -Wall -Llib -Wl,--unresolved-symbols=ignore-in-shared-libs
LDLIBS := -lm -lpigpio -lwpilibc -lwpiHal -lcameraserver -lntcore -lcscore -lopencv_dnn -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_videoio -lopencv_imgcodecs -lopencv_features2d -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_core -lwpiutil -latomic
LDLIBS := -lm -lpigpio -lwpilibc -lwpiHal -lcameraserver -lntcore -lcscore -lopencv_dnn -lopencv_highgui -lopencv_ml \
-lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d \
-lopencv_videoio -lopencv_imgcodecs -lopencv_features2d -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann \
-lopencv_core -lwpiutil -latomic

ifneq (,$(findstring windows,$(mode))) #windows
CXX := $(CROSS_PREFIX)$(CXX)
Expand All @@ -64,9 +67,18 @@ all: $(PROGRAM)
rebuild: all | clean

#compile for each source
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(OBJ_DIR)/%.cpp.o : $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CXX) $(COPT) -c -o $(OBJ_DIR)/$(@F) -std=c++17 $(CPPFLAGS) $(CFLAGS) $<

$(OBJ_DIR)/%.c.o : $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CXX) $(COPT) -c -o $(OBJ_DIR)/$(@F) -std=c++17 $(CPPFLAGS) $(CFLAGS) $<

$(OBJ_DIR)/%.S.o : $(SRC_DIR)/%.S | $(OBJ_DIR)
$(CXX) $(COPT) -c -o $(OBJ_DIR)/$(@F) -std=c++17 $(ASMFLAGS) $(CPPFLAGS) $(CFLAGS) $<

$(OBJ_DIR)/%.s.o : $(SRC_DIR)/%.s | $(OBJ_DIR)
$(CXX) $(COPT) -c -o $(OBJ_DIR)/$(@F) -std=c++17 $(ASMFLAGS) $(CPPFLAGS) $(CFLAGS) $<

#link all objects
$(PROGRAM): $(OBJS) | $(BIN_DIR)
$(CXX) $(LOPT) -o $@ $(LDFLAGS) $(foreach file,$(^F),$(OBJ_DIR)/$(file)) $(LDLIBS)
Expand Down
88 changes: 88 additions & 0 deletions makefile.backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# https://www.gnu.org/software/make/manual/html_node/index.html
# https://stackoverflow.com/questions/30573481/how-to-write-a-makefile-with-separate-source-and-header-directories
# https://stackoverflow.com/questions/2826029/passing-additional-variables-from-command-line-to-make
# https://web.stanford.edu/class/archive/cs/cs107/cs107.1174/guide_make.html

# Compiler Options: https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html
# -pthread -> link POSIX thread library - use in compiling AND linking
# -g -> compile for use with debug tools (GDB)
# -O -> optimization preference (O0 is default, O{1-3} set different levels (3 is the most optimized), Og optimizes but includes debug info, -Ofast and -Os also exist)
# -c -> compile only (no linking)
# -o{file} -> output to {file}, usually a '.o'
# -I{path} -> INCLUDE this path in header search
# -W(all) -> compiler warning level (commonly set to 'all', but other options exist)
# -l{libname} -> link with {libname} - remember that libraries all start with 'lib' then end in an extention - {libname} only refers to the name between those - ex. libLIBRARY.so -> -lLIBRARY
# -L{path} -> add a path in which to search for specified libs (-l's, see above)
# -Wl,{option} -> pass an option to the linker (this is only here because it was used in the source Makefile)

#rwildcard = $(foreach d,$(wildcard $(addsuffix *,$(1))),$(call rwildcard,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d)))

mode ?= windows-release

CROSS_PREFIX := arm-raspbian10-linux-gnueabihf-
CXX := g++

SRC_DIR := src
OBJ_DIR := obj
BIN_DIR := bin

PROGRAM := $(BIN_DIR)/vision_program
#SRC := $(wildcard $(SRC_DIR)/*.cpp)
SRC_T := $(wildcard $(SRC_DIR)/*.cpp) $(wildcard $(SRC_DIR)/extras/*.cpp)
#SRC_R := $(wildcard $(SRC_DIR)/*.cpp) $(wildcard $(SRC_DIR)/**/*.cpp)
#SRC_R := $(call rwildcard,$(SRC_DIR)/,*.cpp)
SRCS := $(SRC_T)
OBJS := $(SRCS:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)

CDEBUG := -g -Og
LDEBUG := -g
CRELEASE := -O3
LRELEASE :=

CPPFLAGS := -pthread -Iinclude -Iinclude/opencv -MMD -MP
CFLAGS := -Wall
LDFLAGS := -pthread -Wall -Llib -Wl,--unresolved-symbols=ignore-in-shared-libs
LDLIBS := -lm -lpigpio -lwpilibc -lwpiHal -lcameraserver -lntcore -lcscore -lopencv_dnn -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_videoio -lopencv_imgcodecs -lopencv_features2d -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_core -lwpiutil -latomic

ifneq (,$(findstring windows,$(mode))) #windows
CXX := $(CROSS_PREFIX)$(CXX)
else #native
endif

ifneq (,$(findstring release,$(mode))) #release
COPT := $(CRELEASE)
LOPT := $(LRELEASE)
else #ifneq (,$(findstring debug,$(mode))) #debug
COPT := $(CDEBUG)
LOPT := $(LDEBUG)
endif

.PHONY: all rebuild clean

all: $(PROGRAM)

rebuild: all | clean

#compile for each source
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CXX) $(COPT) -c -o $(OBJ_DIR)/$(@F) -std=c++17 $(CPPFLAGS) $(CFLAGS) $<

#link all objects
$(PROGRAM): $(OBJS) | $(BIN_DIR)
$(CXX) $(LOPT) -o $@ $(LDFLAGS) $(foreach file,$(^F),$(OBJ_DIR)/$(file)) $(LDLIBS)

#create dirs if nonexistant
$(BIN_DIR) $(OBJ_DIR):
mkdir $@

#install: all
# cp runCamera $(BIN_DIR)

clean:
ifneq (,$(findstring windows,$(mode)))#find a better solution for windows, as this doesn't work if the dirs are not empty (kind of pointless)
rmdir $(OBJ_DIR) $(BIN_DIR)
else
$(RM) -rv $(OBJ_DIR) $(BIN_DIR)
endif

-include $(OBJS:.o=.d)
Binary file removed obj/VisionTesting.vcxproj.AssemblyReference.cache
Binary file not shown.
6 changes: 0 additions & 6 deletions obj/basic.d

This file was deleted.

Binary file removed obj/basic.o
Binary file not shown.
131 changes: 0 additions & 131 deletions obj/cameraconfig.d

This file was deleted.

Binary file removed obj/cameraconfig.o
Binary file not shown.
Loading

0 comments on commit a443be1

Please sign in to comment.