-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OpenCV support for IDF (IEC-35) #94
base: master
Are you sure you want to change the base?
Conversation
|
dcc144b
to
5702a49
Compare
5702a49
to
635c5ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @dmitry1945 , I left few comments.
It is difficult for me to review the functional part, I have not worked with OpenCV... :/
This project used to build and include OpenCV library into the esp-idf as a component for esp32, esp32s2 and esp32s3 CPUs. | ||
Now the opencv could be build with IDF version 4.4. | ||
This component was tested with opencv V 4.6.0 | ||
The build is working only on Linux machines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should fix the build for Windows and macOS before release
# 2.1. Add here if the component is compatible with IDF == v4.3 | ||
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_EQUAL "4.3") | ||
if(NOT ((${IDF_TARGET} MATCHES "esp32c3") OR (${IDF_TARGET} MATCHES "esp32c2"))) | ||
list(APPEND EXTRA_COMPONENT_DIRS ../opencv) | ||
endif() | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Readme and in idf_component.yml you claim that OpenCV is compatible with IDF 4.4 only.
- What is the limitation for other versions?
- Why do you add it to v4.3 test_app here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we can't get OpenCV to build with IDF v5.x because OpenCV source code has some issues with uint32_t == unsigned long
.
We'll add a patch to make it work with IDF 5.x and then update this PR.
Apologies if I shouldn't be posting here, I am just wondering if this is still in the works. |
@ucfncouch This is still in the works, currently blocked on an upstream PR. We speed things up, we are going to release opencv component to components.espressif.com first, and handle upstreaming of these small fixes later. |
@ucfncouch yes, it still in work. The release depends on pull request for OpenCV. |
@dmitry1945 @igrr Great! Thanks for the response. I have been doing some work with OpenCV on the ESP32 & ESP32s3 using a modified build, and many things had to be disabled to get it working correctly. Glad to see this is in the works. In your testing, are there many things that have to be disabled to get it working? |
@ucfncouch Here the list of enabled opencv features: If you will create your application, you should just include opencv as an idf component to the list of components in the CMakeLists.txt, for example:
, and it should work without any changes of opencv or removing something. Even now you can use this component with upstream opencv, but with IDF-5.1. And, you will need to adjust partition table like this:
because opencv take some space inside of memory. We will release the component soon with examples. Regards, |
Incredible! I am going to be doing some extensive testing with this soon after it is released to compare to the OpenCV build I am using. As I said the way I am doing it currently is extremely limiting and a lot of core functionality is either broken or takes some large workarounds. I very much appreciate this! |
@ucfncouch OpenCV component has been published: https://components.espressif.com/components/espressif/opencv. Please give it a try, feedback is welcome! |
Hello little update I've tried to add this dependency to the esp-idf blink example project and I get this error in the build:
Target "idf::opencv" not found. CMake Error at /usr/share/cmake-3.22/Modules/ExternalProject.cmake:2406:EVAL:2 (add_custom_command):
Target "idf::opencv" not found. CMake Error at /usr/share/cmake-3.22/Modules/ExternalProject.cmake:2406:EVAL:2 (add_custom_command):
Target "idf::opencv" not found. CMake Error at /usr/share/cmake-3.22/Modules/ExternalProject.cmake:2406:EVAL:2 (add_custom_command):
Target "idf::opencv" not found. CMake Error at /usr/share/cmake-3.22/Modules/ExternalProject.cmake:2406:EVAL:2 (add_custom_command):
Target "idf::opencv" not found. CMake Error at /usr/share/cmake-3.22/Modules/ExternalProject.cmake:2406:EVAL:2 (add_custom_command):
Target "idf::opencv" not found. -- Generating done |
Great! Thanks for the work on this. I will be testing it here over the next few days/weeks. I will open an issue if I encounter anything out of the ordinary that I cannot fix myself. |
I am also getting a similar problem @igrr. |
Ok, it seems I was able to resolve one of the problems but am now running into another. If you create a project from one of the opencv examples as recommended on the IDF Component Page you will run into a problem because of the main CMakeLists. It is setting the component directory as: set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/../..") which is causing it to back out of the project, I am assuming this is because these examples are originally buried within the managed components folder. I changed it to: set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/..") which is solving the problem of the components not being added to the project but I am encountering a separate issue as mentioned. This is also the same output I get if I run from the example within managed components instead of creating a new project. -- Found Git: C:/Users/na258588/.espressif/tools/idf-git/2.39.2/cmd/git.exe (found version "2.39.2.windows.1")
Call Stack (most recent call first):
This warning is for project developers. Use -Wno-dev to suppress it. fatal: not a git repository (or any of the parent directories): .git CMake Error at
Call Stack (most recent call first):
Call Stack (most recent call first): -- Configuring incomplete, errors occurred!
|
Actually just did a sanity check and tried to build a fresh project with only esp32-camera as a dependency and I ran into the exact same error message. I am a little bit confused about what I am overlooking. Edit: Was able to get hello_world to build so I knew IDF wasn't borked. Seems that whenever I try and add a component using the IDF component manager I get the build errors that are linked above ^. I must be doing something wrong... Edit 1/22/24 - I still have not been able to find a solution to this problem, I have been digging through various posts and the documentation with no change. Not sure what I am doing wrong here. |
@Ncouch64 @NathanG-Wyca Please change the directory of opencv to "components" and change the file name to "opencv". @igrr you can set COMPONENT_NAME variable as "opencv" before calling "idf_component_register" macro. This will solve the build error. |
Thanks for the tip @ahmetcobanoglu, we'll fix that as well as other related issues and will release the new version soon. |
I will test this out today, thanks for the response. I was pulling my hair out trying to figure out what I was doing wrong. |
@Ncouch64 I will update opencv component today. You will be able to use it. |
Thank you! Very excited. |
Thanks for the useful library.
It works correctly if I disable the IF block at the end of the code.
Enabling an IF block at the end of the code will cause a build error. My Environment:
imread function is not supported.
|
Yes, I have worked with OpenCV on ESP devices before the component was released and there as well IM and related functions were not going to work. You will need to write a function to output the data to MicroSD if you are trying to save it. If you are just trying to work with images captured from the sensor you will need to turn the data to CV.Mat. The features 2d example should show how to do this pretty well. |
@https://github.com/Ncouch64
What makes me wonder is that the source for these functions exists.
|
Yeah I am not quite sure why this is the case, I am sure @igrr or @dmitry1945 would be able to explain better. All I know is that in both cases where I have used OpenCV on esp im functions could not be utilized. Maybe there is a way to get them working? Maybe it cannot be done on ESP? |
ESP-IDF doesn't have these libraries, so I think it's probably not possible.
|
@nopnop2002 the OpenCV component has this library in the list (libjpeg-turbo libwebp libpng libtiff libjasper zlib). It should work. |
Pls try to build this code:
|
@nopnop2002 yes, I did it. The update will be soon. |
Wow this is great to hear, so we should be able to use imwrite to save to SD instead of a function workaround that ive been using? |
@nopnop2002, @Ncouch64, the component is ready. Please download the latest one. Regards, |
Do I need to make any changes to main/CMakeLists.txt? If you have any changes, please share the main/CMakeLists.txt you used. I used 4.7.0~5. If you need build logging, I'll share it. |
Did you fix your problem with the component? |
Hi,I noticed that HAVE_OPENCV_DNN is undefined in the current project, is ESP32 unable to support this option? |
Hi, so I am throwing my hat into some OpenCV stuff. Note to others about joachimBurket/esp32-opencv and ESP32-CAM, I made a PR fixing that and added IDF 5.3.0 support: |
As far as I know, and have tested, much of OpenCV is available to use as part of this component. There are currently some issues with it, for example I cannot save to SD card when using the component and FAST corner detection does not work, but other aspects of OpenCV does work. I believe this is something that is still being worked on. Depending on what you are looking to do, it may already be possible on ESP. https://github.com/joachimBurket/esp32-opencv/ | is what I was using before they released the component. There are many base issues with it and I had to do a lot of work-arounds to get what I wanted to do working with it. If the remaining issues with the component can be smoothed out, its absolutely the way to go. Much easier to work with. |
Checklist
url
field definedChange description
The component include opencv as a component for the esp-idf.
The component could be used now with idf 4.x. The build of test_app not passed because some problems with /bdc_motor component, not with opencv.
Regards,
Dmitry