diff --git a/packages/dartcv/.gitignore b/packages/dartcv/.gitignore index 3cceda5..eee74c3 100644 --- a/packages/dartcv/.gitignore +++ b/packages/dartcv/.gitignore @@ -5,3 +5,6 @@ # Avoid committing pubspec.lock for library packages; see # https://dart.dev/guides/libraries/private-files#pubspeclock. pubspec.lock + +test/models +libdartcv* diff --git a/packages/dartcv/.pubignore b/packages/dartcv/.pubignore new file mode 100644 index 0000000..01f0aa0 --- /dev/null +++ b/packages/dartcv/.pubignore @@ -0,0 +1,15 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock + +test/images +test/images_out +test/models +src/ +ffigen/ +Makefile +libdartcv* diff --git a/packages/dartcv/CHANGELOG.md b/packages/dartcv/CHANGELOG.md index effe43c..b78d64c 100644 --- a/packages/dartcv/CHANGELOG.md +++ b/packages/dartcv/CHANGELOG.md @@ -1,3 +1,3 @@ -## 1.0.0 +## 0.0.1 - Initial version. diff --git a/packages/dartcv/LICENSE b/packages/dartcv/LICENSE new file mode 100644 index 0000000..b900fe5 --- /dev/null +++ b/packages/dartcv/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2024] [rainyl] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/dartcv/README.md b/packages/dartcv/README.md index 8831761..ccb294f 100644 --- a/packages/dartcv/README.md +++ b/packages/dartcv/README.md @@ -1,39 +1,18 @@ - +[dartcv](https://pub.dev/packages/dartcv) is only for pure dart, for Flutter, use [opencv_core](https://pub.dev/packages/opencv_core), +if videoio module is required, use [opencv_dart](https://pub.dev/packages/opencv_dart) -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. +## Install -## Features - -TODO: List what your package can do. Maybe include images, gifs, or videos. - -## Getting started - -TODO: List prerequisites and provide or point to information on how to -start using the package. - -## Usage - -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. - -```dart -const like = 'sample'; -``` - -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. +- `dart pub add dartcv` or Add dartcv to `pubspec.yaml` +- Prepare libraries for your platform, you have 2 options (macos: please build from source.) + - build from source, see [workflows](https://github.com/rainyl/dartcv/tree/main/.github/workflows) + - download prebuilt libraries from [release](https://github.com/rainyl/dartcv/releases) + - move/copy the libraries to a directory, e.g., `~/.dartcv` +- Setup environment variables + - windows: append the above path to `PATH` + - linux: append the above path to `LD_LIBRARY_PATH` + - macos: append the above path to `DYLD_LIBRARY_PATH` diff --git a/packages/dartcv/lib/src/g/types.g.dart b/packages/dartcv/lib/src/g/types.g.dart index ebc1741..87ccba0 100644 --- a/packages/dartcv/lib/src/g/types.g.dart +++ b/packages/dartcv/lib/src/g/types.g.dart @@ -382,7 +382,7 @@ final class RotatedRect extends ffi.Struct { external CvSize2f size; - @ffi.Double() + @ffi.Float() external double angle; } diff --git a/packages/dartcv/pubspec.yaml b/packages/dartcv/pubspec.yaml index d5f71b6..2275f2d 100644 --- a/packages/dartcv/pubspec.yaml +++ b/packages/dartcv/pubspec.yaml @@ -1,6 +1,10 @@ name: dartcv -description: "OpenCV bindings for Dart language. dartcv is for pure dart only, for flutter, please use opencv_dart." -version: 1.0.0 +description: | + OpenCV bindings for Dart language. + dartcv is for pure dart only, + for flutter, please use [opencv_core](https://pub.dev/packages/opencv_core), + if you need videoio module, use [opencv_dart](https://pub.dev/packages/opencv_dart). +version: 0.0.1 homepage: https://github.com/rainyl/opencv_dart/packages/dartcv environment: diff --git a/packages/dartcv/test/gapi/structs_test.dart b/packages/dartcv/test/gapi/structs_test.dart index a7ab79f..1253875 100644 --- a/packages/dartcv/test/gapi/structs_test.dart +++ b/packages/dartcv/test/gapi/structs_test.dart @@ -1,5 +1,7 @@ -import 'package:dartcv/gapi.dart' as cv_gapi; +@Skip('GAPI not finished') + import 'package:dartcv/dartcv.dart' as cv; +import 'package:dartcv/gapi.dart' as cv_gapi; import 'package:test/test.dart'; void main() { diff --git a/packages/dartcv/test/videoio/videoio_async_test.dart b/packages/dartcv/test/videoio/videoio_async_test.dart new file mode 100644 index 0000000..16a5d62 --- /dev/null +++ b/packages/dartcv/test/videoio/videoio_async_test.dart @@ -0,0 +1,54 @@ +import 'package:dartcv/dartcv.dart' as cv; +import 'package:test/test.dart'; + +void main() async { + // videoio + test('cv.VideoWriterAsync.emptyAsync', () async { + final writer = await cv.VideoWriterAsync.emptyAsync(); + expect(writer.isOpened, equals(false)); + await writer.openAsync("test/images/small2.mp4", "mp4v", 60, (400, 300)); + await writer.releaseAsync(); + + expect(await cv.VideoWriterAsync.fourccAsync("MJPG"), closeTo(1196444237, 1e-3)); + + writer.dispose(); + }); + + test('cv.VideoWriterAsync.openAsync', () async { + final writer = await cv.VideoWriterAsync.fromFileAsync("test/images/small2.mp4", "mp4v", 60, (400, 300)); + final frame = cv.Mat.ones(400, 300, cv.MatType.CV_8UC3); + await writer.writeAsync(frame); + await writer.releaseAsync(); + }); + + test('cv.VideoCaptureAsync.emptyAsync', () async { + final vc = await cv.VideoCaptureAsync.emptyAsync(); + expect(vc.isOpened, false); + final success = await vc.openAsync("test/images/small.mp4", apiPreference: cv.CAP_ANY); + expect(success, true); + await vc.releaseAsync(); + + vc.dispose(); + }); + + test('cv.VideoCaptureAsync.fromFileAsync', () async { + final vc = await cv.VideoCaptureAsync.fromFileAsync("test/images/small.mp4", apiPreference: cv.CAP_ANY); + final (success, frame) = await vc.readAsync(); + expect(success, true); + expect(frame.isEmpty, false); + expect(vc.codec, "h264"); + + expect(cv.VideoCapture.toCodec("h264"), closeTo(875967080, 1e-3)); + // cv.imwrite("cv.VideoCapture.fromFile.png", frame); + }); + + // Disable for github + test('cv.VideoCaptureAsync.fromDeviceAsync', skip: true, () async { + final vc = await cv.VideoCaptureAsync.fromDeviceAsync(0); + expect(vc.isOpened, true); + final (res, frame) = await vc.readAsync(); + expect(res, true); + expect(frame.isEmpty, false); + // cv.imwrite("cv.VideoCapture.fromDevice_1.png", frame); + }); +} diff --git a/packages/dartcv/test/videoio/videoio_test.dart b/packages/dartcv/test/videoio/videoio_test.dart new file mode 100644 index 0000000..2b10da6 --- /dev/null +++ b/packages/dartcv/test/videoio/videoio_test.dart @@ -0,0 +1,66 @@ +import 'package:dartcv/dartcv.dart' as cv; +import 'package:test/test.dart'; + +void main() async { + // videoio + test('cv.VideoWriter.empty', () { + final writer = cv.VideoWriter.empty(); + expect(writer.isOpened, equals(false)); + writer.open("test/images/small2.mp4", "mp4v", 60, (400, 300)); + writer.open("test/images/small2.mp4", "mp4v", 60, (400, 300), apiPreference: cv.CAP_FFMPEG); + writer.release(); + + expect(cv.VideoWriter.fourcc("MJPG"), closeTo(1196444237, 1e-3)); + + writer.dispose(); + }); + + test('cv.VideoWriter.fromFile', () { + final writer = cv.VideoWriter.fromFile("test/images/small2.mp4", "mp4v", 60, (400, 300)); + final frame = cv.Mat.ones(400, 300, cv.MatType.CV_8UC3); + writer.write(frame); + writer.release(); + final writer1 = cv.VideoWriter.fromFile( + "test/images/small2.mp4", + "mp4v", + 60, + (400, 300), + apiPreference: cv.CAP_FFMPEG, + ); + expect(writer1.isOpened, true); + }); + + test('cv.VideoCapture.empty', () { + final vc = cv.VideoCapture.empty(); + expect(vc.isOpened, false); + final success = vc.open("test/images/small.mp4", apiPreference: cv.CAP_ANY); + expect(success, true); + vc.release(); + + vc.dispose(); + }); + + test('cv.VideoCapture.fromFile', () { + final vc = cv.VideoCapture.fromFile("test/images/small.mp4", apiPreference: cv.CAP_ANY); + final (success, frame) = vc.read(); + expect(success, true); + expect(frame.isEmpty, false); + + expect(vc.getBackendName(), isNotEmpty); + + expect(vc.codec, "h264"); + + expect(cv.VideoCapture.toCodec("h264"), closeTo(875967080, 1e-3)); + // cv.imwrite("cv.VideoCapture.fromFile.png", frame); + }); + + // Disable for github + test('cv.VideoCapture.fromDevice', skip: true, () { + final vc = cv.VideoCapture.fromDevice(0); + expect(vc.isOpened, true); + final (res, frame) = vc.read(); + expect(res, true); + expect(frame.isEmpty, false); + // cv.imwrite("cv.VideoCapture.fromDevice_1.png", frame); + }); +} diff --git a/packages/opencv_core/pubspec.yaml b/packages/opencv_core/pubspec.yaml index 92a40eb..06f563d 100644 --- a/packages/opencv_core/pubspec.yaml +++ b/packages/opencv_core/pubspec.yaml @@ -4,6 +4,8 @@ description: | This plugin does NOT include highgui and videoio modules, if you need them, please use opencv_dart instead. version: 1.2.6 +opencv_version: 4.10.0+9 +dartcv_version: 4.10.0+2 homepage: https://github.com/rainyl/opencv_dart environment: @@ -13,8 +15,7 @@ environment: dependencies: flutter: sdk: flutter - dartcv: - path: ../dartcv + dartcv: ^0.0.1 dev_dependencies: test: ^1.25.2 diff --git a/packages/opencv_core/src/CMakeLists.txt b/packages/opencv_core/src/CMakeLists.txt index 975f0ea..424ebe5 100644 --- a/packages/opencv_core/src/CMakeLists.txt +++ b/packages/opencv_core/src/CMakeLists.txt @@ -1,7 +1,30 @@ cmake_minimum_required(VERSION 3.14) +get_filename_component(PROJ_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) + +macro(_find_version _version_var _version_file _regex_find _regex_replace) + # read versions + if(EXISTS ${_version_file}) + file(STRINGS ${_version_file} _version_string REGEX ${_regex_find}) + string(REGEX REPLACE ${_regex_replace} "\\1" _version_string "${_version_string}") + set(${_version_var} "${_version_string}") + else() + message(FATAL_ERROR "file ${_version_file} not found!") + endif() +endmacro() + +_find_version(_version_project "${PROJ_DIR}/pubspec.yaml" "^version: (.+)*$" "version: (.+)*$") +_find_version(_version_opencv "${PROJ_DIR}/pubspec.yaml" "^opencv_version: (.+)*$" "opencv_version: (.+)*$") +_find_version(_version_dartcv "${PROJ_DIR}/pubspec.yaml" "^dartcv_version: (.+)*$" "dartcv_version: (.+)*$") + +message(STATUS "Project Version: ${_version_project}") +message(STATUS "OpenCV Version: ${_version_opencv}") +message(STATUS "DartCv Version: ${_version_dartcv}") + project(dartcv LANGUAGES CXX VERSION 1.0.0) +set(PROJECT_VERSION "${_version_project}") + # Flutter doesn't support build android-x86, disable here # https://docs.flutter.dev/deployment/android#what-are-the-supported-target-architectures if(ANDROID AND(DEFINED ANDROID_ABI)) @@ -26,16 +49,16 @@ set(DARTCV_WITH_GAPI OFF) set(DARTCV_WORLD OFF) # TODO: read opencv_version from pubspec.yaml -set(OPENCV_VERSION "4.10.0+9") +set(OPENCV_VERSION "${_version_opencv}") set(DARTCV_DISABLE_DOWNLOAD_OPENCV OFF) include(FetchContent) FetchContent_Declare( - dartcv + libdartcv GIT_REPOSITORY https://github.com/rainyl/dartcv.git - GIT_TAG 61effe0762f7919b38f1da58d87c9aa541ee1569 + GIT_TAG ${_version_dartcv} ) -FetchContent_MakeAvailable(dartcv) +FetchContent_MakeAvailable(libdartcv) if(ANDROID) message(STATUS "Installing ${FFMPEG_LIB_PATHS} to ${CMAKE_INSTALL_PREFIX}") diff --git a/packages/opencv_core/windows/CMakeLists.txt b/packages/opencv_core/windows/CMakeLists.txt index e720784..769fa45 100644 --- a/packages/opencv_core/windows/CMakeLists.txt +++ b/packages/opencv_core/windows/CMakeLists.txt @@ -8,6 +8,12 @@ cmake_minimum_required(VERSION 3.14) set(PROJECT_NAME "opencv_core") project(${PROJECT_NAME} LANGUAGES CXX) +# disable warnings +set (CMAKE_C_FLAGS "/wd4244 /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE ${CMAKE_C_FLAGS}") +set (CMAKE_C_FLAGS "/wd4244 /D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE ${CMAKE_C_FLAGS}") +set (CMAKE_CXX_FLAGS "/wd4244 /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE ${CMAKE_CXX_FLAGS}") +set (CMAKE_CXX_FLAGS "/wd4244 /D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE ${CMAKE_CXX_FLAGS}") + # Invoke the build for native code shared with the other target platforms. # This can be changed to accommodate different builds. add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") diff --git a/packages/opencv_dart/example/android/app/build.gradle b/packages/opencv_dart/example/android/app/build.gradle index 47e9ac6..6d906e1 100644 --- a/packages/opencv_dart/example/android/app/build.gradle +++ b/packages/opencv_dart/example/android/app/build.gradle @@ -24,7 +24,7 @@ android { applicationId = "dev.rainyl.opencv_dart_example" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. - minSdk = flutter.minSdkVersion + minSdk = 24 targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName diff --git a/packages/opencv_dart/linux/CMakeLists.txt b/packages/opencv_dart/linux/CMakeLists.txt index fe398e5..4126ff3 100644 --- a/packages/opencv_dart/linux/CMakeLists.txt +++ b/packages/opencv_dart/linux/CMakeLists.txt @@ -10,7 +10,7 @@ project(${PROJECT_NAME} LANGUAGES CXX VERSION 1.0.0) # Invoke the build for native code shared with the other target platforms. # This can be changed to accommodate different builds. -# add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") # List of absolute paths to libraries that should be bundled with the plugin. # This list could contain prebuilt libraries, or libraries created by an diff --git a/packages/opencv_dart/pubspec.yaml b/packages/opencv_dart/pubspec.yaml index c894d06..d74f532 100644 --- a/packages/opencv_dart/pubspec.yaml +++ b/packages/opencv_dart/pubspec.yaml @@ -5,7 +5,9 @@ description: | please use opencv_core instead. The most complete OpenCV bindings for Dart! With asynchronous support now! -version: 1.2.5 +version: 1.2.6 +opencv_version: 4.10.0+9 +dartcv_version: 4.10.0+2 homepage: https://github.com/rainyl/opencv_dart environment: @@ -15,8 +17,7 @@ environment: dependencies: flutter: sdk: flutter - dartcv: - path: ../dartcv + dartcv: 0.0.1 dev_dependencies: test: ^1.25.2 diff --git a/packages/opencv_dart/src/CMakeLists.txt b/packages/opencv_dart/src/CMakeLists.txt index 150c1fa..544ff8b 100644 --- a/packages/opencv_dart/src/CMakeLists.txt +++ b/packages/opencv_dart/src/CMakeLists.txt @@ -1,7 +1,30 @@ cmake_minimum_required(VERSION 3.14) +get_filename_component(PROJ_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) + +macro(_find_version _version_var _version_file _regex_find _regex_replace) + # read versions + if(EXISTS ${_version_file}) + file(STRINGS ${_version_file} _version_string REGEX ${_regex_find}) + string(REGEX REPLACE ${_regex_replace} "\\1" _version_string "${_version_string}") + set(${_version_var} "${_version_string}") + else() + message(FATAL_ERROR "file ${_version_file} not found!") + endif() +endmacro() + +_find_version(_version_project "${PROJ_DIR}/pubspec.yaml" "^version: (.+)*$" "version: (.+)*$") +_find_version(_version_opencv "${PROJ_DIR}/pubspec.yaml" "^opencv_version: (.+)*$" "opencv_version: (.+)*$") +_find_version(_version_dartcv "${PROJ_DIR}/pubspec.yaml" "^dartcv_version: (.+)*$" "dartcv_version: (.+)*$") + +message(STATUS "Project Version: ${_version_project}") +message(STATUS "OpenCV Version: ${_version_opencv}") +message(STATUS "DartCv Version: ${_version_dartcv}") + project(dartcv LANGUAGES CXX VERSION 1.0.0) +set(PROJECT_VERSION "${_version_project}") + # Flutter doesn't support build android-x86, disable here # https://docs.flutter.dev/deployment/android#what-are-the-supported-target-architectures if(ANDROID AND(DEFINED ANDROID_ABI)) @@ -26,16 +49,16 @@ set(DARTCV_WITH_GAPI OFF) set(DARTCV_WORLD OFF) # TODO: read opencv_version from pubspec.yaml -set(OPENCV_VERSION "4.10.0+9") +set(OPENCV_VERSION "${_version_opencv}") set(DARTCV_DISABLE_DOWNLOAD_OPENCV OFF) include(FetchContent) FetchContent_Declare( - dartcv + libdartcv GIT_REPOSITORY https://github.com/rainyl/dartcv.git - GIT_TAG 61effe0762f7919b38f1da58d87c9aa541ee1569 + GIT_TAG ${_version_dartcv} ) -FetchContent_MakeAvailable(dartcv) +FetchContent_MakeAvailable(libdartcv) if(ANDROID) message(STATUS "Installing ${FFMPEG_LIB_PATHS} to ${CMAKE_INSTALL_PREFIX}") diff --git a/packages/opencv_dart/windows/CMakeLists.txt b/packages/opencv_dart/windows/CMakeLists.txt index 74d792d..7c9e4b0 100644 --- a/packages/opencv_dart/windows/CMakeLists.txt +++ b/packages/opencv_dart/windows/CMakeLists.txt @@ -22,6 +22,12 @@ set(FFMPEG_USE_STATIC_LIBS OFF) # This can be changed to accommodate different builds. add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") +if(NOT FFMPEG_LIB_PATHS) + message(FATAL_ERROR "FFMPEG library paths not found!") +else() + message(STATUS "FFMPEG_LIB_PATHS: ${FFMPEG_LIB_PATHS}") +endif() + # List of absolute paths to libraries that should be bundled with the plugin. # This list could contain prebuilt libraries, or libraries created by an # external build triggered from this build file.