I am working on a project which requires to deploy custom algorithm on microcontrollers.
I used some basic functions from opnecv especially cv::Mat.
I want to compile the header files under the /core/ with rest of the cpp and hpp without installing opencv or using -lopencv_core flags.
Some idea of the hardware is that the memory limit is 1mb, currently compiled code is 12 mb which is using imgproc, highgui [This will be removed], videoio libraries.
Thanks, Please I would love to hear ideas and thoughts.
you could try to build / link a static version of opencv_core,
so you dont have to deploy a seperate so/dll,
by adding -DBUILD_SHARED_LIBS=OFF to the cmake cmdline
also: -DBUILD_LIST=core,imgproc` to avoid building other (unwanted) modules
however,
with static libs, you dont need to install/deploy the so’s (assuming you cross-compile)
but you still need -lopencv_imgproc -lopencv_core -littnotify -lrt -ldl -lz -lpthread to link your own prog
and just for comparison - libopencv_core.so is 10.3mb here, but a (stripped) prog, statically linked against core only is 2.7mb
I am not clear. I already have opencv installed on the system.
After your comment I am not sure which case should I proceed with. Case 1, run the cmake as it is but with suggested flags from your response. Case 2, where I should copy the header files I need, and then run the cmake.
So, I understand your comment better now. I am still having difficulty since lack of my experience in Cmake
I am using opencv3.4.19, and this is the error
/usr/bin/ld: attempted static link of dynamic object `/usr/local/lib/libopencv_highgui.so.3.4.19’
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/csrt.dir/build.make:179: csrt] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/csrt.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Dynamic linking is working as expected, but not with static. Thanks again.
Currently buidling opencv library statically.
Error I am getting.
/usr/bin/ld: cannot find -littnotify
/usr/bin/ld: /home/nile649/opencv_build/opencv/build/lib/libopencv_core.a(opencl_core.cpp.o): in function `opencl_check_fn(int)':
opencl_core.cpp:(.text._ZL15opencl_check_fni+0xe1): warning: Using ‘dlopen’ in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/csrt.dir/build.make:178: csrt] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/csrt.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Above issues resolved, I am updating the cmake file
The current errors
Errors regarding window_gtk.cpp
window_gtk.cpp:(.text.cvResizeWindow+0x10a): undefined reference to `gtk_window_resize’
Errors regarding the ffmpeg
cap_ffmpeg.cpp:(.text.ZN23InputMediaStream_FFMPEG4openEPKcPiS2_S2_S2+0x9a): undefined reference to `avformat_network_init’
Errors regarding the cap_gstreamer.cpp
cap_gstreamer.cpp:(.text._ZN2cv23CvVideoWriter_GStreamerD2Ev[_ZN2cv23CvVideoWriter_GStreamerD5Ev]+0x4d): undefined reference to `gst_object_unref’
what kind of hardware are you trying with, exactly ??
what kind of os is there (if at all !) ?
do you really expect to connect it to a monitor & run windowed programs / gui ?
where would your (image) input come from ?
do you actually need video(file / url) handling (i doubt so !) ?
cut down the requirements to a bare minimum, before proceeding !
`
above is the cmake config, after over conversation on this thread I now understand how to compile and get the static library work. I am really thankful.
Issue, I am trying to get the CSRT tracker from the contrib to get working on the microcontroller. The size went upto 15mb.