-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* do not compile qtmultimedia from source (#34) * Android open cv (#35) * Use the latest release of openCV action and work also for android * Only look for core and objdetect components of openCV * Added request permission for a camera * Ask for permission and look for a backcamera * Choose the lowest resolution format * Use threads for decoding * Set public USE_EMSCRIPTEN * added flash for Android
- Loading branch information
Showing
9 changed files
with
301 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@PACKAGE_INIT@ | ||
include(CMakeFindDependencyMacro) | ||
find_dependency(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick Svg OPTIONAL_COMPONENTS Multimedia ) | ||
find_dependency(OpenCV QUIET ) | ||
find_dependency(OpenCV REQUIRED COMPONENTS core objdetect ) | ||
include ( "${CMAKE_CURRENT_LIST_DIR}/qrCodeTargets.cmake" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
find_package(OpenCV) | ||
if(NOT OpenCV_FOUND AND NOT ANDROID) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/download/v0.0.14/OpenCV-ubuntu-latest-wasm_false.tar") | ||
if(WIN32) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/download/v0.0.14/OpenCV-windows-latest-wasm_false.tar") | ||
endif(WIN32) | ||
if (APPLE) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/download/v0.0.14/OpenCV-macos-latest-wasm_false.tar") | ||
endif(APPLE) | ||
if(EMSCRIPTEN) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/download/v0.0.14/OpenCV-ubuntu-latest-wasm_true.tar") | ||
endif(EMSCRIPTEN) | ||
FetchContent_Declare( | ||
OpenCV | ||
DOWNLOAD_EXTRACT_TIMESTAMP true | ||
URL ${builturl} | ||
) | ||
FetchContent_GetProperties(OpenCV) | ||
if(NOT OpenCV_POPULATED) | ||
message(STATUS "OpenCV prebuilt will be downloaded from ${builturl} if not found on the system") | ||
FetchContent_Populate(OpenCV) | ||
message(STATUS "OpenCV is installed in ${opencv_SOURCE_DIR}") | ||
set(OpenCV_DIR ${opencv_SOURCE_DIR}/lib/cmake/opencv4) | ||
if(WIN32) | ||
set(OpenCV_DIR ${opencv_SOURCE_DIR}) | ||
endif(WIN32) | ||
find_package(OpenCV) | ||
endif() | ||
find_package(OpenCV COMPONENTS core objdetect ) | ||
if(NOT OpenCV_FOUND ) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/latest/download/OpenCV-ubuntu-latest-wasm_false-android_none.tar") | ||
if(WIN32) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/latest/download/OpenCV-windows-latest-wasm_false-android_none.tar") | ||
endif(WIN32) | ||
if (APPLE) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/latest/download/OpenCV-macos-latest-wasm_false-android_none.tar") | ||
endif(APPLE) | ||
if(EMSCRIPTEN) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/latest/download/OpenCV-ubuntu-latest-wasm_true-android_none.tar") | ||
endif(EMSCRIPTEN) | ||
if(ANDROID) | ||
set(builturl "https://github.com/EddyTheCo/install-OpenCV-action/releases/latest/download/OpenCV-ubuntu-latest-wasm_false-android_${ANDROID_ABI}.tar") | ||
endif(ANDROID) | ||
FetchContent_Declare( | ||
OpenCV | ||
DOWNLOAD_EXTRACT_TIMESTAMP true | ||
URL ${builturl} | ||
) | ||
FetchContent_GetProperties(OpenCV) | ||
if(NOT OpenCV_POPULATED) | ||
message(STATUS "OpenCV prebuilt will be downloaded from ${builturl} if not found on the system") | ||
FetchContent_Populate(OpenCV) | ||
message(STATUS "OpenCV is installed in ${opencv_SOURCE_DIR}") | ||
set(OpenCV_DIR ${opencv_SOURCE_DIR}/lib/cmake/opencv4) | ||
if(WIN32) | ||
set(OpenCV_DIR ${opencv_SOURCE_DIR}) | ||
endif(WIN32) | ||
if(ANDROID) | ||
set(OpenCV_DIR ${opencv_SOURCE_DIR}/sdk/native/jni) | ||
endif(ANDROID) | ||
find_package(OpenCV COMPONENTS core objdetect) | ||
endif() | ||
endif() | ||
|
||
|
||
|
||
if(OpenCV_FOUND) | ||
|
||
add_library(QrDec qrcodedec.cpp) | ||
|
||
set_target_properties(QrDec PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
|
||
target_include_directories(QrDec PRIVATE ${OpenCV_INCLUDE_DIRS}) | ||
target_link_libraries(QrDec PRIVATE ${OpenCV_LIBS}) | ||
|
||
target_include_directories(QrDec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>") | ||
|
||
install(TARGETS QrDec | ||
EXPORT qrCodeTargets | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
COMPONENT Qr | ||
) | ||
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qrCode | ||
COMPONENT Qr | ||
) | ||
add_library(QrDec qrcodedec.cpp) | ||
|
||
target_include_directories(QrDec PUBLIC $<BUILD_INTERFACE:${OpenCV_INCLUDE_DIRS}>) | ||
target_link_libraries(QrDec PUBLIC ${OpenCV_LIBS}) | ||
|
||
target_include_directories(QrDec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>") | ||
install(TARGETS QrDec | ||
EXPORT qrCodeTargets | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
COMPONENT Qr | ||
) | ||
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qrCode | ||
COMPONENT Qr | ||
) | ||
else() | ||
message(STATUS "OpenCV was not found") | ||
message(STATUS "OpenCV was not found") | ||
endif(OpenCV_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
#pragma once | ||
#include<iostream> | ||
#include<opencv2/opencv.hpp> | ||
#include <opencv2/objdetect.hpp> | ||
#include<string> | ||
#include<vector> | ||
|
||
namespace qrcodedec { | ||
class QRDecoder : public cv::QRCodeDetector | ||
{ | ||
|
||
std::string decode_grey(unsigned char* img, int rows,int cols); | ||
public: | ||
QRDecoder(){}; | ||
std::string decode_grey(unsigned char* img, int rows,int cols); | ||
}; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
#include<qrcodedec.hpp> | ||
#include<opencv2/opencv.hpp> | ||
|
||
namespace qrcodedec { | ||
using namespace std; | ||
using namespace cv; | ||
string decode_grey(unsigned char* img,int rows ,int cols) | ||
{ | ||
Mat greyImg = Mat(rows,cols, CV_8UC1, img); | ||
QRCodeDetector* decoder = new QRCodeDetector(); | ||
auto str=decoder->detectAndDecode(greyImg); | ||
delete decoder; | ||
return str; | ||
} | ||
std::string QRDecoder::decode_grey(unsigned char* img,int rows ,int cols) | ||
{ | ||
cv::Mat greyImg = cv::Mat(rows,cols, CV_8UC1, img); | ||
return detectAndDecodeCurved(greyImg); | ||
} | ||
|
||
|
||
|
||
} | ||
#ifdef USE_EMSCRIPTEN | ||
EMSCRIPTEN_BINDINGS(qrcodedec) { | ||
function("decode_grey", &qrcodedec::decode_grey); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.