mirror of
https://gitcode.com/gh_mirrors/es/esp32-opencv.git
synced 2025-08-06 18:24:38 +08:00
Added basic example and started tests example
- Basic example only makes some matrices and apply basic operations on them - Tests example test every useful for embedded system features of opencv
This commit is contained in:
@ -2,4 +2,4 @@
|
|||||||
# CMakeLists in this exact order for cmake to work correctly
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(esp_opencv)
|
project(esp_opencv_basic)
|
3
esp32/examples/esp_opencv_basic/README.md
Normal file
3
esp32/examples/esp_opencv_basic/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Esp32 OpenCV basic
|
||||||
|
|
||||||
|
This is a basic example to test that OpenCV works correctly. The project only creates some matrices and apply basic operations on them.
|
18
esp32/examples/esp_opencv_basic/main/CMakeLists.txt
Normal file
18
esp32/examples/esp_opencv_basic/main/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
set(COMPONENT_SRCS "hello_opencv.cpp")
|
||||||
|
set(COMPONENT_ADD_INCLUDEDIRS "." "./opencv/")
|
||||||
|
register_component()
|
||||||
|
|
||||||
|
# Be aware that the order of the librairies is important
|
||||||
|
add_prebuilt_library(opencv_imgcodecs "opencv/libopencv_imgcodecs.a")
|
||||||
|
add_prebuilt_library(libpng "opencv/3rdparty/liblibpng.a")
|
||||||
|
add_prebuilt_library(libzlib "opencv/3rdparty/libzlib.a")
|
||||||
|
add_prebuilt_library(opencv_imgproc "opencv/libopencv_imgproc.a")
|
||||||
|
add_prebuilt_library(opencv_core "opencv/libopencv_core.a")
|
||||||
|
add_prebuilt_library(ade "opencv/libade.a")
|
||||||
|
|
||||||
|
target_link_libraries(${COMPONENT_LIB} PRIVATE opencv_imgcodecs)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} PRIVATE libpng)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} PRIVATE libzlib)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} PRIVATE opencv_imgproc)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} PRIVATE opencv_core)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} PRIVATE ade)
|
60
esp32/examples/esp_opencv_basic/main/hello_opencv.cpp
Normal file
60
esp32/examples/esp_opencv_basic/main/hello_opencv.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#include "opencv2/core.hpp"
|
||||||
|
#include "opencv2/imgproc.hpp"
|
||||||
|
#include "opencv2/imgcodecs.hpp"
|
||||||
|
|
||||||
|
#include <esp_log.h>
|
||||||
|
#include <string>
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <esp_err.h>
|
||||||
|
#include <esp_spiffs.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace cv;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
static char TAG[]="hello_opencv";
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
void app_main(void);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Starting main");
|
||||||
|
|
||||||
|
/* Matrices initialization tests */
|
||||||
|
Mat M1(2,2, CV_8UC3, Scalar(0,0,255));
|
||||||
|
cout << "M1 = " << endl << " " << M1 << endl << endl;
|
||||||
|
|
||||||
|
Mat M2(2,2, CV_8UC3, Scalar(0,0,111));
|
||||||
|
cout << "M2 = " << endl << " " << M2 << endl << endl;
|
||||||
|
|
||||||
|
Mat eye = Mat::eye(10, 10, CV_32F) * 0.1;
|
||||||
|
cout << "eye = " << endl << " " << eye << endl << endl;
|
||||||
|
|
||||||
|
Mat ones = Mat::ones(15, 4, CV_8U)*3;
|
||||||
|
cout << "ones = " << endl << " " << ones << endl << endl;
|
||||||
|
|
||||||
|
vector<float> v;
|
||||||
|
v.push_back((float)CV_PI);
|
||||||
|
v.push_back(2);
|
||||||
|
v.push_back(3.01f);
|
||||||
|
cout << "floats vector = " << endl << " " << Mat(v) << endl << endl;
|
||||||
|
|
||||||
|
/* Matrices imgproc operations tests */
|
||||||
|
uint8_t data[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||||
|
Mat M3 = Mat(3, 5, CV_8UC1, data);
|
||||||
|
cout << "Gray matrix = " << endl << " " << M3 << endl << endl;
|
||||||
|
|
||||||
|
Mat M4;
|
||||||
|
threshold(M3, M4, 7, 255, THRESH_BINARY);
|
||||||
|
cout << "Thresholded matrix = " << endl << " " << M4 << endl << endl;
|
||||||
|
|
||||||
|
Mat M5;
|
||||||
|
resize(M3, M5, Size(), 0.75, 0.75);
|
||||||
|
cout << "Resized matrix = " << endl << " " << M5 << endl << endl;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user