diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..dab07df1f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,83 @@ +# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\Projects\randd\randd_address_separator\dotnet\Sansan.RD.AddressSeparator.Tests\ codebase based on best match to current usage at 2022/08/18 +# You can modify the rules from these initially generated values to suit your own policies +# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference +[*.cs] + + +# IDE0160: Convert to file-scoped namespace +csharp_style_namespace_declarations = file_scoped:warning + +#Core editorconfig formatting - indentation + +#use soft tabs (spaces) for indentation +indent_style = space + +#Formatting - new line options + +#require braces to be on a new line for methods and types (also known as "Allman" style) +csharp_new_line_before_open_brace = all#methods, types + +#Formatting - organize using options + +#sort System.* using directives alphabetically, and place them before other usings +dotnet_sort_system_directives_first = true + +#Formatting - spacing options + +#remove space between method call name and opening parenthesis +csharp_space_between_method_call_name_and_opening_parenthesis = false +#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call +csharp_space_between_method_call_parameter_list_parentheses = false +#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. +csharp_space_between_method_declaration_parameter_list_parentheses = false + +#Style - expression bodied member options + +#prefer block bodies for methods +csharp_style_expression_bodied_methods = when_on_single_line:suggestion + +#Style - implicit and explicit types + +#prefer var over explicit type in all cases, unless overridden by another code style rule +csharp_style_var_elsewhere = true:suggestion +#prefer var is used to declare variables with built-in system types such as int +csharp_style_var_for_built_in_types = true:suggestion + +#Style - language keyword and framework type options + +#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion + +#Style - modifier options + +#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods. +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +#Style - Modifier preferences + +#when this rule is set to a list of modifiers, prefer the specified ordering. +csharp_preferred_modifier_order = public,internal:suggestion + + +# CA1711: Identifiers should not have incorrect suffix +dotnet_diagnostic.CA1711.severity = none + +# CA5393: Do not use unsafe DllImportSearchPath value +dotnet_diagnostic.CA5393.severity = none + +# https://docs.microsoft.com/ja-jp/dotnet/fundamentals/code-analysis/quality-rules/ca1051 +# TODO: not working?? +dotnet_diagnostic.ca1051.exclude_structs = true + +# CA1014: Mark assemblies with CLSCompliantAttribute +dotnet_diagnostic.CA1014.severity = none + +# IDE0079: Remove unnecessary suppression +dotnet_diagnostic.IDE0079.severity = none + + +[*.{cs,vb}] +dotnet_style_allow_statement_immediately_after_block_experimental=false:silent + +[*] +insert_final_newline = true diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..ab3791cf8 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: shimat diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index db75675ad..fd8065d1a 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,15 +1,18 @@ # Summary of your issue + + # Environment Write your environment. # What did you do when you faced the problem? -//write here +Write here ## Example code: + ``` paste your core code ``` @@ -17,6 +20,7 @@ paste your core code ## Output: + ``` paste your output ``` diff --git a/.github/docker-appengine.yml b/.github/docker-appengine.yml new file mode 100644 index 000000000..305bc1114 --- /dev/null +++ b/.github/docker-appengine.yml @@ -0,0 +1,23 @@ +name: Docker gcr.io/google-appengine/aspnetcore + +on: + pull_request: + types: [synchronize, opened] + +env: + DEBIAN_FRONTEND: noninteractive + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: docker build + run: | + cd docker/appengine-aspnetcore3.1-opencv4.5.1 + docker build -t shimat/appengine-aspnetcore3.1-opencv4.5.1 . diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 000000000..c71e631de --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 180 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false \ No newline at end of file diff --git a/.github/workflows/docfx.yml b/.github/workflows/docfx.yml new file mode 100644 index 000000000..3035fc5c6 --- /dev/null +++ b/.github/workflows/docfx.yml @@ -0,0 +1,56 @@ +name: DocFX + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v2 + + - name: DocFX + shell: cmd + run: | + choco install docfx -y + docfx docfx\docfx.json + + - name: Upload DocFX packages + uses: actions/upload-artifact@v4 + with: + name: docfx_site + path: ${{ github.workspace }}\docfx\_site + + - uses: actions/upload-pages-artifact@v3 + with: + path: docfx/_site + + deploy: + needs: build + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/docker-deploy-ubuntu20.yml b/.github/workflows/docker-deploy-ubuntu20.yml new file mode 100644 index 000000000..77f98d595 --- /dev/null +++ b/.github/workflows/docker-deploy-ubuntu20.yml @@ -0,0 +1,48 @@ +name: Publish Ubuntu Docker Image + +on: + workflow_dispatch: + inputs: + docker_image_tag: + description: 'Docker Image Tag (yyyyMMdd)' + required: true + +env: + DEBIAN_FRONTEND: noninteractive + DOCKER_IMAGE_NAME1: "ubuntu22-dotnet6-opencv4.7.0" + DOCKER_IMAGE_NAME2: "ubuntu22-dotnet6sdk-opencv4.7.0" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: validate input + run: | + if [[ ! ${{ github.event.inputs.docker_image_tag }} =~ ^[0-9]{8}$ ]]; then + echo "::error Invalid tag name '${{ github.event.inputs.docker_image_tag }}'" + exit 1 + fi + + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: docker build 1 + run: | + cd docker/${DOCKER_IMAGE_NAME1} + docker build -t ghcr.io/shimat/opencvsharp/${DOCKER_IMAGE_NAME1}:${{ github.event.inputs.docker_image_tag }} . + + - name: docker build 2 + run: | + cd docker/${DOCKER_IMAGE_NAME2} + docker build -t ghcr.io/shimat/opencvsharp/${DOCKER_IMAGE_NAME2}:${{ github.event.inputs.docker_image_tag }} . + + - name: docker login + run: | + echo ${{secrets.GH_PACKAGES_PAT}} | docker login ghcr.io -u shimat --password-stdin + + - name: docker push + run: | + docker push ghcr.io/shimat/opencvsharp/${DOCKER_IMAGE_NAME1}:${{ github.event.inputs.docker_image_tag }} + docker push ghcr.io/shimat/opencvsharp/${DOCKER_IMAGE_NAME2}:${{ github.event.inputs.docker_image_tag }} diff --git a/.github/workflows/docker-ubuntu20.yml b/.github/workflows/docker-ubuntu20.yml new file mode 100644 index 000000000..3b8cb454b --- /dev/null +++ b/.github/workflows/docker-ubuntu20.yml @@ -0,0 +1,21 @@ +name: Docker mcr.microsoft.com/dotnet/sdk:6.0-focal + +on: + pull_request: + types: [synchronize, opened] + +env: + DEBIAN_FRONTEND: noninteractive + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: docker build + run: | + cd docker/ubuntu22-dotnet6sdk-opencv4.7.0 + docker build -t shimat/ubuntu22-dotnet6sdk-opencv4.7.0 . diff --git a/.github/workflows/linux-arm.yml b/.github/workflows/linux-arm.yml new file mode 100644 index 000000000..d21d7ee89 --- /dev/null +++ b/.github/workflows/linux-arm.yml @@ -0,0 +1,50 @@ +name: Linux ARM (Docker) + +on: + pull_request: + types: [synchronize, opened] + push: + branches: + - main + +env: + DEBIAN_FRONTEND: noninteractive + OPENCV_VERSION: 4.11.0 + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - uses: docker/setup-buildx-action@v3 + with: + install: true + + - uses: docker/setup-qemu-action@v3 + + - name: Build with Docker + run: | + # Override OpenCV version in Dockerfile + docker build \ + -t opencvsharp-linux-arm:latest \ + --output=type=docker \ + --platform=linux/arm/v7 \ + --build-arg OPENCV_VERSION \ + ./docker/ubuntu22-dotnet6-opencv4.8.0 + + - name: Extract build files from Docker instance + run: | + docker create -ti --name opencvsharp-linux-arm-tmp opencvsharp-linux-arm bash + docker cp opencvsharp-linux-arm-tmp:/artifacts . + + - name: Patch nuspec with version and build NuGet package + run: | + sed -E --in-place=.bak "s/[0-9]\.[0-9]{1,2}\.[0-9]{1,2}.[0-9]{8}(-beta[0-9]*)?<\/version>/${OPENCV_VERSION}.$(date '+%Y%m%d')<\/version>/" nuget/OpenCvSharp4.runtime.linux-arm.nuspec + cp artifacts/libOpenCvSharpExtern.so nuget/ + dotnet pack nuget/OpenCvSharp4.runtime.linux-arm.csproj -o artifacts_arm + + - uses: actions/upload-artifact@v4 + with: + name: artifacts_linux_arm + path: artifacts_arm diff --git a/.github/workflows/macos10.yml.disabled b/.github/workflows/macos10.yml.disabled new file mode 100644 index 000000000..6335c77ca --- /dev/null +++ b/.github/workflows/macos10.yml.disabled @@ -0,0 +1,145 @@ +name: macOS 10.15 + +on: + pull_request: + types: [synchronize, opened] + push: + branches: + - main + +env: + DEBIAN_FRONTEND: noninteractive + OPENCV_VERSION: 4.8.0 + +jobs: + build: + + runs-on: macos-11 + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Install build dependencies + run: | + brew install wget pkg-config mono-libgdiplus gtk+ ffmpeg@4 glog yasm harfbuzz jpeg libpng libtiff openjpeg metis openblas opencore-amr protobuf tbb webp # openexr + +# - name: Cache OpenCV +# id: opencv-cache +# uses: actions/cache@v3 +# with: +# path: ${{ github.workspace }}/opencv_macos/ +# key: opencv-${{ env.OPENCV_VERSION }}-macos-rev1 + + - name: Build OpenCV + if: steps.opencv-cache.outputs.cache-hit != 'true' + run: | + pwd + wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -Oopencv-${OPENCV_VERSION}.zip && unzip opencv-${OPENCV_VERSION}.zip + wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip -Oopencv_contrib-${OPENCV_VERSION}.zip && unzip opencv_contrib-${OPENCV_VERSION}.zip + cd opencv-${OPENCV_VERSION} && mkdir build && cd build + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \ + -DBUILD_SHARED_LIBS=OFF \ + -DENABLE_CXX11=ON -DBUILD_TESTS=OFF \ + -DBUILD_PERF_TESTS=OFF \ + -DBUILD_DOCS=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_JAVA=OFF \ + -DBUILD_opencv_java_bindings_generator=OFF \ + -DBUILD_opencv_python_bindings_generator=OFF \ + -DBUILD_opencv_python_tests=OFF \ + -DBUILD_opencv_ts=OFF \ + -DBUILD_opencv_js=OFF \ + -DBUILD_opencv_js_bindings_generator=OFF \ + -DBUILD_opencv_apps=OFF \ + -DBUILD_opencv_barcode=OFF \ + -DBUILD_opencv_bioinspired=OFF \ + -DBUILD_opencv_ccalib=OFF \ + -DBUILD_opencv_datasets=OFF \ + -DBUILD_opencv_dnn_objdetect=OFF \ + -DBUILD_opencv_dpm=OFF \ + -DBUILD_opencv_fuzzy=OFF \ + -DBUILD_opencv_gapi=ON \ + -DBUILD_opencv_intensity_transform=OFF \ + -DBUILD_opencv_mcc=OFF \ + -DBUILD_opencv_objc_bindings_generator=OFF \ + -DBUILD_opencv_rapid=OFF \ + -DBUILD_opencv_reg=OFF \ + -DBUILD_opencv_stereo=OFF \ + -DBUILD_opencv_structured_light=OFF \ + -DBUILD_opencv_surface_matching=OFF \ + -DBUILD_opencv_wechat_qrcode=ON \ + -DBUILD_opencv_videostab=OFF \ + -DWITH_GSTREAMER=OFF \ + -DWITH_EIGEN=OFF \ + -DWITH_ADE=OFF \ + -DWITH_OPENEXR=OFF \ + -DOPENCV_ENABLE_NONFREE=ON \ + -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_macos .. + make -j2 + make install + cd ${GITHUB_WORKSPACE} + ls + + - name: Build OpenCvSharpExtern + run: | + pwd + mkdir src/build && cd $_ + cmake -DCMAKE_BUILD_TYPE=Release -D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_macos .. + make -j2 + ls + ls OpenCvSharpExtern + cp OpenCvSharpExtern/libOpenCvSharpExtern.dylib ${GITHUB_WORKSPACE}/nuget/ + + - name: Check OpenCvSharpExtern + run: | + cd ${GITHUB_WORKSPACE}/nuget/ + otool -L libOpenCvSharpExtern.dylib + nm libOpenCvSharpExtern.dylib + echo -ne "#include \n int core_Mat_sizeof(); int main(){ int i = core_Mat_sizeof(); printf(\"sizeof(Mat) = %d\", i); return 0; }" > test.c + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern + LD_LIBRARY_PATH=. ./test + + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.0.x' + + - name: Create NuGet package + env: + BETA: "" + run: | + yyyymmdd=`date '+%Y%m%d'` + echo $yyyymmdd + sed -E -i=.bak "s/[0-9]\.[0-9]{1,2}\.[0-9]{1,2}.[0-9]{8}(-beta[0-9]*)?<\/version>/${OPENCV_VERSION}.${yyyymmdd}${BETA}<\/version>/" ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.osx.10.15-x64.nuspec + cat ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.osx.10.15-x64.nuspec + dotnet pack ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.osx.10.15-x64.csproj -o ${GITHUB_WORKSPACE}/artifacts_macos + ls ${GITHUB_WORKSPACE}/artifacts_macos + + - uses: actions/upload-artifact@v3 + with: + name: artifacts_macos_10 + path: artifacts_macos + + - name: Test + run: | + cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests + # ls + dotnet build -c Release -f net6.0 + cp ${GITHUB_WORKSPACE}/nuget/libOpenCvSharpExtern.dylib ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/bin/Release/net6.0/ + cp ${GITHUB_WORKSPACE}/nuget/libOpenCvSharpExtern.dylib ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/ + # ls ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/bin/Release/net6.0/ + # ls + sudo cp ${GITHUB_WORKSPACE}/nuget/libOpenCvSharpExtern.dylib /usr/local/lib/ + LD_LIBRARY_PATH=. + dotnet test OpenCvSharp.Tests.csproj -c Release -f net6.0 --runtime osx-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null + ls + ls TestResults + + - uses: actions/upload-artifact@v1 + with: + name: artifacts_macos_10_test_results + path: test/OpenCvSharp.Tests/TestResults/test-results.trx diff --git a/.github/workflows/publish_nuget.yml b/.github/workflows/publish_nuget.yml new file mode 100644 index 000000000..21e0878ea --- /dev/null +++ b/.github/workflows/publish_nuget.yml @@ -0,0 +1,65 @@ +name: Publish NuGet + +on: + workflow_dispatch: + +jobs: + Publish: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + + - name: Download windows artifact + uses: dawidd6/action-download-artifact@v6 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: windows.yml + name: packages_windows + + - name: Download ubuntu artifact + uses: dawidd6/action-download-artifact@v8 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: ubuntu22.yml + name: artifacts_ubuntu_22 + + - name: Download ubuntu arm artifact + uses: dawidd6/action-download-artifact@v8 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: linux-arm.yml + name: artifacts_linux_arm + + #- name: Download macos artifact + # uses: dawidd6/action-download-artifact@v6 + # with: + # github_token: ${{secrets.GITHUB_TOKEN}} + # workflow: macos10.yml + # name: artifacts_macos_10 + + - name: Download wasm artifact + uses: dawidd6/action-download-artifact@v8 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: wasm.yml + name: artifacts_wasm + + - run: | + ls -l + + - name: Install .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Rename + run: | + for f in $(find $PWD -maxdepth 1 -regex ".+\.s?nupkg"); do + dotnet run --project tool/OpenCvSharp.NupkgBetaRemover --configuration Release -- "$f" + done + + - name: Push to nuget.org + run: | + dotnet nuget push "*.nupkg" -k ${{secrets.NUGET_ORG_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate + dotnet nuget push "*.snupkg" -k ${{secrets.NUGET_ORG_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate diff --git a/.github/workflows/ubuntu22.yml b/.github/workflows/ubuntu22.yml new file mode 100644 index 000000000..cc61be85b --- /dev/null +++ b/.github/workflows/ubuntu22.yml @@ -0,0 +1,173 @@ +name: Ubuntu 22.04 + +on: + pull_request: + types: [synchronize, opened] + push: + branches: + - main + +env: + DEBIAN_FRONTEND: noninteractive + OPENCV_VERSION: 4.11.0 + OPENCV_CACHE_VERSION: 1 + +jobs: + build: + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + path: opencvsharp + + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y --no-install-recommends \ + apt-transport-https \ + software-properties-common \ + ca-certificates \ + g++ \ + make \ + cmake \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + x264 \ + libtesseract-dev + + - name: Cache OpenCV + id: opencv-cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/opencv_artifacts/ + key: opencv-${{ env.OPENCV_VERSION }}-rev${{ env.OPENCV_CACHE_VERSION }} + + - name: Checkout OpenCV + if: steps.opencv-cache.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: opencv/opencv + path: opencv + ref: ${{ env.OPENCV_VERSION }} + - name: Checkout OpenCV Contrib + if: steps.opencv-cache.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: opencv/opencv_contrib + path: opencv_contrib + ref: ${{ env.OPENCV_VERSION }} + + - name: Build OpenCV + if: steps.opencv-cache.outputs.cache-hit != 'true' + run: | + mkdir opencv/build && cd opencv/build + cmake \ + -S . \ + -B build \ + -D CMAKE_BUILD_TYPE=Release \ + -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_apps=OFF \ + -D BUILD_opencv_barcode=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_js_bindings_generator=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=ON \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_objc_bindings_generator=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ + -D BUILD_opencv_videostab=OFF \ + -D WITH_GSTREAMER=OFF \ + -D WITH_ADE=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + -D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_artifacts .. + cmake --build build + cmake --install build + sudo ldconfig + cd ${GITHUB_WORKSPACE} + ls + + - name: Build OpenCvSharpExtern + run: | + mkdir opencvsharp/src/build && cd $_ + cmake -D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_artifacts .. + make -j + ls OpenCvSharpExtern + cp OpenCvSharpExtern/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/nuget/ + + - name: Check OpenCvSharpExtern + run: | + cd ${GITHUB_WORKSPACE}/opencvsharp/nuget/ + ldd libOpenCvSharpExtern.so + nm libOpenCvSharpExtern.so + echo -ne "#include \n int core_Mat_sizeof(); int main(){ int i = core_Mat_sizeof(); printf(\"sizeof(Mat) = %d\", i); return 0; }" > test.c + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern + LD_LIBRARY_PATH=. ./test + + - name: Install .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Create NuGet package + env: + BETA: "" + run: | + yyyymmdd=`date '+%Y%m%d'` + echo $yyyymmdd + cd ${GITHUB_WORKSPACE}/opencvsharp + sed -E --in-place=.bak \ + "s/[0-9]\.[0-9]{1,2}\.[0-9]{1,2}.[0-9]{8}(-beta[0-9]*)?<\/version>/${OPENCV_VERSION}.${yyyymmdd}${BETA}<\/version>/" \ + nuget/OpenCvSharp4.official.runtime.linux-x64.nuspec + cat nuget/OpenCvSharp4.official.runtime.linux-x64.nuspec + dotnet pack nuget/OpenCvSharp4.official.runtime.linux-x64.csproj -o ${GITHUB_WORKSPACE}/artifacts_ubuntu + ls ${GITHUB_WORKSPACE}/artifacts_ubuntu + + - uses: actions/upload-artifact@v4 + with: + name: artifacts_ubuntu_22 + path: artifacts_ubuntu + + - name: Test + run: | + cd ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests + dotnet build -c Release -f net8.0 + cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests/bin/Release/net8.0/ + cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests/ + sudo cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so /usr/lib/ + LD_LIBRARY_PATH=. dotnet test OpenCvSharp.Tests.csproj -c Release -f net8.0 --runtime linux-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml new file mode 100644 index 000000000..07826af59 --- /dev/null +++ b/.github/workflows/wasm.yml @@ -0,0 +1,176 @@ +name: Wasm + +on: + pull_request: + types: [synchronize, opened] + push: + branches: + - main + +env: + DEBIAN_FRONTEND: noninteractive + OPENCV_VERSION: 4.11.0 + EM_VERSION: 3.1.32 + EM_CACHE_FOLDER: 'emsdk-cache' + +jobs: + build: + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Install dependencies + run: | + pwd + echo ${GITHUB_WORKSPACE} + current_path=$(pwd) + sudo apt-get update -y + sudo apt-get install -y --no-install-recommends \ + apt-transport-https \ + software-properties-common \ + wget \ + unzip \ + ca-certificates \ + g++ \ + make \ + cmake \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + x264 \ + libtesseract-dev + + - name: Cache OpenCV + id: opencv-cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/opencv_wasm/ + key: opencv-${{ env.OPENCV_VERSION }}-wasm + + - name: Setup Emscripten cache + id: cache-system-libraries + uses: actions/cache@v4 + with: + path: ${{env.EM_CACHE_FOLDER}} + key: ${{env.EM_VERSION}}-${{ runner.os }} + - uses: mymindstorm/setup-emsdk@v14 + with: + version: ${{env.EM_VERSION}} + actions-cache-folder: ${{env.EM_CACHE_FOLDER}} + + - name: Build OpenCV + if: steps.opencv-cache.outputs.cache-hit != 'true' + run: | + wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -Oopencv-${OPENCV_VERSION}.zip && unzip opencv-${OPENCV_VERSION}.zip + wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip -Oopencv_contrib-${OPENCV_VERSION}.zip && unzip opencv_contrib-${OPENCV_VERSION}.zip + cd opencv-${OPENCV_VERSION} && mkdir build && cd build + emcmake cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \ + -DBUILD_SHARED_LIBS=OFF \ + -DENABLE_CXX11=ON -DBUILD_TESTS=OFF \ + -DBUILD_PERF_TESTS=OFF \ + -DBUILD_DOCS=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_JAVA=OFF \ + -DBUILD_opencv_java_bindings_generator=OFF \ + -DBUILD_opencv_python_bindings_generator=OFF \ + -DBUILD_opencv_python_tests=OFF \ + -DBUILD_opencv_ts=OFF \ + -DBUILD_opencv_js=OFF \ + -DBUILD_opencv_js_bindings_generator=OFF \ + -DBUILD_opencv_apps=OFF \ + -DBUILD_opencv_barcode=OFF \ + -DBUILD_opencv_bioinspired=OFF \ + -DBUILD_opencv_ccalib=OFF \ + -DBUILD_opencv_datasets=OFF \ + -DBUILD_opencv_dnn_objdetect=OFF \ + -DBUILD_opencv_dpm=OFF \ + -DBUILD_opencv_fuzzy=OFF \ + -DBUILD_opencv_gapi=ON \ + -DBUILD_opencv_intensity_transform=OFF \ + -DBUILD_opencv_mcc=OFF \ + -DBUILD_opencv_objc_bindings_generator=OFF \ + -DBUILD_opencv_rapid=OFF \ + -DBUILD_opencv_reg=OFF \ + -DBUILD_opencv_stereo=OFF \ + -DBUILD_opencv_structured_light=OFF \ + -DBUILD_opencv_surface_matching=OFF \ + -DBUILD_opencv_wechat_qrcode=ON \ + -DBUILD_opencv_videostab=OFF \ + -DWITH_GSTREAMER=OFF \ + -DWITH_EIGEN=OFF \ + -DWITH_ADE=OFF \ + -DOPENCV_ENABLE_NONFREE=ON \ + -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_wasm \ + -DCMAKE_C_FLAGS='-s WASM=1' -DCMAKE_CXX_FLAGS='-s WASM=1' \ + -DWITH_ITT=OFF \ + -DWITH_JPEG=OFF \ + -DWITH_TIFF=OFF \ + -DWITH_PNG=OFF \ + -DWITH_IPP=OFF \ + -DWITH_LAPACK=OFF \ + -DCV_ENABLE_INTRINSICS=OFF \ + -DBUILD_opencv_dnn=ON \ + .. + make -j + make install + em++ -r -o ${GITHUB_WORKSPACE}/opencv_wasm/libopencv.o \ + -Wl,--whole-archive ${GITHUB_WORKSPACE}/opencv_wasm/lib/*.a \ + ${GITHUB_WORKSPACE}/opencv_wasm/lib/opencv4/3rdparty/*.a + cd ${GITHUB_WORKSPACE} + ls + + - name: Build OpenCvSharpExtern + run: | + ls ${GITHUB_WORKSPACE}/opencv_wasm + echo "-----" + mkdir src/build && cd $_ + emcmake cmake -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=${GITHUB_WORKSPACE}/opencv_wasm/lib/cmake/opencv4 -DWASM_LIB=${GITHUB_WORKSPACE}/opencv_wasm/libopencv.o .. + make -j + ls OpenCvSharpExtern + cp OpenCvSharpExtern/libOpenCvSharpExtern.a ${GITHUB_WORKSPACE}/nuget/ + + - name: Check OpenCvSharpExtern + run: | + echo TODO + + - name: Install .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Create NuGet package + env: + BETA: "" + run: | + yyyymmdd=`date '+%Y%m%d'` + echo $yyyymmdd + sed -E --in-place=.bak "s/[0-9]\.[0-9]{1,2}\.[0-9]{1,2}.[0-9]{8}(-beta[0-9]*)?<\/version>/${OPENCV_VERSION}.${yyyymmdd}${BETA}<\/version>/" ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.wasm.nuspec + cat ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.wasm.nuspec + dotnet pack ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.wasm.csproj -o ${GITHUB_WORKSPACE}/artifacts_wasm + ls ${GITHUB_WORKSPACE}/artifacts_wasm + + - uses: actions/upload-artifact@v4 + with: + name: artifacts_wasm + path: artifacts_wasm + + - name: Test + run: | + echo TODO diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 000000000..082b09b7a --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,179 @@ +name: Windows Server 2022 + +on: + pull_request: + types: [synchronize, opened] + push: + branches: + - main + +env: + OPENCV_VERSION: "4.11.0" + OPENCV_FILES_TAG: "4.11.0.20250505" + TESSERACT_RELEASE_VERSION: "2024.08.19" + +jobs: + build: + + runs-on: windows-2022 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + submodules: true + +# - name: Cache restored NuGet packages +# uses: actions/cache@v2 +# with: +# path: ${{ github.workspace }}/.nuget/packages +# key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} +# restore-keys: | +# ${{ runner.os }}-nuget- + + - name: Cache OpenCV binaries + id: cache_opencv + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/opencv_files + key: opencv-${{ env.OPENCV_VERSION }}-rev1 + + - name: Download OpenCV binaries + if: steps.cache_opencv.outputs.cache-hit != 'true' + shell: powershell + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release download --repo shimat/opencv_files ${env:OPENCV_FILES_TAG} --pattern "opencv_win_x64.zip" + gh release download --repo shimat/opencv_files ${env:OPENCV_FILES_TAG} --pattern "opencv_win_x86.zip" + Expand-Archive -Path opencv_win_x64.zip -DestinationPath opencv_files/opencv_win_x64 -Force -ErrorAction Stop + Expand-Archive -Path opencv_win_x86.zip -DestinationPath opencv_files/opencv_win_x86 -Force -ErrorAction Stop + ls opencv_files + ls opencv_files/opencv_win_x64 + + - name: Cache Tesseract binaries + id: cache_tesseract + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/tesseract_files + key: tesseract-41-rev2 + + - name: Download Tesseract binaries + if: steps.cache_tesseract.outputs.cache-hit != 'true' + shell: powershell + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release download --repo shimat/tesseract_vcpkg ${TESSERACT_RELEASE_VERSION} --pattern "*.zip" --output tesseract.zip + Expand-Archive -Path tesseract.zip -DestinationPath tesseract_files -Force -ErrorAction Stop + ls tesseract_files + Move-Item tesseract_files/tesseract_vcpkg.0.0.9-beta tesseract_files/tesseract_vcpkg + ls tesseract_files/tesseract_vcpkg + New-Item tesseract_files/tesseract_vcpkg -ItemType Directory -Force + Move-Item tesseract_files/tesseract_vcpkg/installed/* tesseract_files/tesseract_vcpkg/ + ls tesseract_files/tesseract_vcpkg + + - name: NuGet restore + shell: cmd + run: | + nuget restore + + - name: Install Server-Media-Foundation + shell: powershell + run: | + Install-WindowsFeature Server-Media-Foundation + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: Build x64 + shell: cmd + run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=x64 -maxcpucount + + - name: Build x86 + shell: cmd + run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=x86 -maxcpucount + + #- name: Build ARM + # shell: cmd + # run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=ARM -maxcpucount + + - name: Install .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 8.0.x + + - name: Build + shell: cmd + run: | + dotnet build src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj -f net6.0 -p:configuration=Release -maxcpucount + dotnet build src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -f net6.0-windows -p:configuration=Release -maxcpucount + + - name: Pack NuGet packages + shell: powershell + run: | + $ErrorActionPreference = "Stop" + + $date = Get-Date -Format "yyyyMMdd" + $version = "${env:OPENCV_VERSION}.${date}-beta" + Write-Host "version = ${version}" + + (Get-ChildItem $env:GITHUB_WORKSPACE -Recurse).Where{ $_.Extension -eq ".nuspec" }.ForEach{ + [xml]$xml = Get-Content $_.FullName + $xml.package.metadata.version = $version + $xml.Save($_.FullName) + } + + $windowsNuspec = "${env:GITHUB_WORKSPACE}\nuget\OpenCvSharp4.Windows.nuspec" + $extensionsNuspec = "${env:GITHUB_WORKSPACE}\nuget\OpenCvSharp4.Extensions.nuspec" + $wpfExtensionsNuspec = "${env:GITHUB_WORKSPACE}\nuget\OpenCvSharp4.WpfExtensions.nuspec" + $nuspecFiles = @($windowsNuspec, $extensionsNuspec, $wpfExtensionsNuspec) + foreach ( $nuspecFile in $nuspecFiles ) { + [xml]$xml = Get-Content $nuspecFile + foreach ($group in $xml.package.metadata.dependencies.ChildNodes){ + foreach ($dependency in $group.ChildNodes){ + $packageId = $dependency.GetAttribute("id") + if ($packageId.StartsWith("OpenCvSharp")){ + Write-Host "before: " $packageId "=" $dependency.GetAttribute("version") + $dependency.SetAttribute("version", $version) + Write-Host "after: " $packageId "=" $dependency.GetAttribute("version") + $xml.Save($nuspecFile) + } + else { + Write-Host "Skipped: " $packageId + } + } + } + } + + nuget pack nuget/OpenCvSharp4.nuspec -OutputDirectory artifacts -Symbols -SymbolPackageFormat snupkg + nuget pack nuget/OpenCvSharp4.Windows.nuspec -OutputDirectory artifacts + nuget pack nuget/OpenCvSharp4.Extensions.nuspec -OutputDirectory artifacts -Symbols -SymbolPackageFormat snupkg + nuget pack nuget/OpenCvSharp4.WpfExtensions.nuspec -OutputDirectory artifacts -Symbols -SymbolPackageFormat snupkg + nuget pack nuget/OpenCvSharp4.runtime.win.nuspec -OutputDirectory artifacts + + - name: Test + shell: powershell + run: | + cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests + dotnet test -c Release -f net48 --runtime win-x64 + + - name: Test Windows-only functions + shell: powershell + run: | + cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.Windows + dotnet test -c Release -f net48 --runtime win-x64 + + - name: Run ReleaseMaker + shell: powershell + run: | + cd "${env:GITHUB_WORKSPACE}\tool\OpenCvSharp.ReleaseMaker" + dotnet run -c Release --runtime win-x64 -- "${env:GITHUB_WORKSPACE}" "${env:GITHUB_WORKSPACE}\artifacts" ${{env.OPENCV_VERSION}} + + - name: Upload NuGet packages and Release packages + uses: actions/upload-artifact@v4 + with: + name: packages_windows + path: ${{ github.workspace }}\artifacts diff --git a/.gitignore b/.gitignore index 1b381679c..6f087b356 100644 --- a/.gitignore +++ b/.gitignore @@ -114,12 +114,13 @@ UpgradeLog*.XML *.BAK /.vs /OpenCvSharp.VC.VC.opendb -/src/OpenCvSharp.Sandbox/foo.yml -/src/OpenCvSharp.Sandbox/dll/x64/OpenCvSharpExtern.dll -/src/OpenCvSharp.Sandbox/dll/x86/OpenCvSharpExtern.dll -/test/OpenCvSharp.Tests/dll/x64/OpenCvSharpExtern.dll -/test/OpenCvSharp.Tests/dll/x86/OpenCvSharpExtern.dll /nuget/nuget/*.nupkg /nuget/*.nupkg /Help /myresults.xml +/opencv_files +/test/OpenCvSharp.Tests/dll/x64/*.dll +/test/OpenCvSharp.Tests/dll/x86/*.dll +/test/OpenCvSharp.Tests/*.dll +Help +/tesseract_files diff --git a/.gitmodules b/.gitmodules index cabf0adc3..ff83a6b21 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "samples"] path = samples url = https://github.com/shimat/opencvsharp_samples.git -[submodule "opencv_files_410"] - path = opencv_files_410 - url = https://github.com/shimat/opencv_files_410 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b65fa74d0..000000000 --- a/.travis.yml +++ /dev/null @@ -1,84 +0,0 @@ -addons: - apt: - packages: libgdiplus - -matrix: - include: - - dist: xenial - before_install: - - pwd - - sudo apt update - - sudo apt -y remove x264 libx264-dev - - sudo apt -y install build-essential checkinstall cmake pkg-config yasm - - sudo apt -y install git gfortran - - sudo apt -y install libjpeg8-dev libpng-dev - - sudo apt -y install software-properties-common - - sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" - - sudo apt -y update - - sudo apt -y install libjasper1 - - sudo apt -y install libtiff-dev - - sudo apt -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev - - sudo apt -y install libxine2-dev libv4l-dev - - cd /usr/include/linux - - sudo ln -s -f ../libv4l1-videodev.h videodev.h - - cd $TRAVIS_BUILD_DIR - - sudo apt -y install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - - sudo apt -y install libgtk2.0-dev libtbb-dev qt5-default - - sudo apt -y install libatlas-base-dev - - sudo apt -y install libfaac-dev libmp3lame-dev libtheora-dev - - sudo apt -y install libvorbis-dev libxvidcore-dev - - sudo apt -y install libopencore-amrnb-dev libopencore-amrwb-dev - - sudo apt -y install libavresample-dev - - sudo apt -y install x264 v4l-utils - - sudo apt -y install libwebp-dev - - sudo apt -y install tesseract-ocr libtesseract-dev libleptonica-dev - before_script: - - echo TRAVIS_SECURE_ENV_VARS = ${TRAVIS_SECURE_ENV_VARS} - - echo TRAVIS_PULL_REQUEST = ${TRAVIS_PULL_REQUEST} - - echo TRAVIS_ALLOW_FAILURE = ${TRAVIS_ALLOW_FAILURE} - - echo TRAVIS_APP_HOST = ${TRAVIS_APP_HOST} - - echo TRAVIS_BRANCH = ${TRAVIS_BRANCH} - - echo TRAVIS_BUILD_DIR = ${TRAVIS_BUILD_DIR} - - echo TRAVIS_BUILD_ID = ${TRAVIS_BUILD_ID} - - echo TRAVIS_BUILD_NUMBER = ${TRAVIS_BUILD_NUMBER} - - echo TRAVIS_BUILD_WEB_URL = ${TRAVIS_BUILD_WEB_URL} - - echo TRAVIS_COMMIT = ${TRAVIS_COMMIT} - - echo TRAVIS_COMMIT_MESSAGE = ${TRAVIS_COMMIT_MESSAGE} - - echo TRAVIS_COMMIT_RANGE = ${TRAVIS_COMMIT_RANGE} - - echo TRAVIS_EVENT_TYPE = ${TRAVIS_EVENT_TYPE} - - echo TRAVIS_JOB_ID = ${TRAVIS_JOB_ID} - - echo TRAVIS_JOB_NAME = ${TRAVIS_JOB_NAME} - - echo TRAVIS_JOB_NUMBER = ${TRAVIS_JOB_NUMBER} - - echo TRAVIS_JOB_WEB_URL = ${TRAVIS_JOB_WEB_URL} - - echo TRAVIS_OS_NAME = ${TRAVIS_OS_NAME} - - echo TRAVIS_OSX_IMAGE = ${TRAVIS_OSX_IMAGE} - - echo TRAVIS_PULL_REQUEST = ${TRAVIS_PULL_REQUEST} - - echo TRAVIS_PULL_REQUEST_BRANCH = ${TRAVIS_PULL_REQUEST_BRANCH} - - echo TRAVIS_PULL_REQUEST_SHA = ${TRAVIS_PULL_REQUEST_SHA} - - echo TRAVIS_PULL_REQUEST_SLUG = ${TRAVIS_PULL_REQUEST_SLUG} - - echo TRAVIS_REPO_SLUG = ${TRAVIS_REPO_SLUG} - - echo TRAVIS_SECURE_ENV_VARS = ${TRAVIS_SECURE_ENV_VARS} - - echo TRAVIS_TEST_RESULT = ${TRAVIS_TEST_RESULT} - - echo TRAVIS_BUILD_STAGE_NAME = ${TRAVIS_BUILD_STAGE_NAME} - - pwd - - wget https://github.com/opencv/opencv/archive/4.1.0.zip -Oopencv-4.1.0.zip - - wget https://github.com/opencv/opencv_contrib/archive/4.1.0.zip -Oopencv_contrib-4.1.0.zip - - unzip opencv-4.1.0.zip - - unzip opencv_contrib-4.1.0.zip - - cd opencv-4.1.0 && mkdir build && cd build - - cmake -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules -DENABLE_CXX11=ON -DBUILD_TESTS=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/opencv_ubuntu .. - - make -j2 - - sudo make install - - sudo ldconfig - - cd ${TRAVIS_BUILD_DIR} - - ls - - ls opencv_ubuntu - script: - - pwd; ls - - mkdir src/build && cd $_ - - cmake -D CMAKE_PREFIX_PATH=${TRAVIS_BUILD_DIR}/opencv_ubuntu .. - - make -j2 - -notifications: - email: - - schimatk@gmail.com \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index b5f2543bd..000000000 --- a/Dockerfile +++ /dev/null @@ -1,133 +0,0 @@ -FROM ubuntu:18.04 AS build-native-env - -ENV OPENCV_VERSION=4.1.0 -#ENV OPENCVSHARP_VERSION=4.1.0.20190416 -#ENV DOTNETCORE_SDK=2.1.104 - -RUN apt update && apt install -y \ - apt-transport-https \ - software-properties-common \ - wget \ - unzip \ - curl \ - ca-certificates - #bzip2 \ - #grep sed dpkg - -# Install opencv dependencies -RUN cd ~ -RUN apt update && apt install -y \ - build-essential \ - cmake \ - git \ - gfortran \ - libjpeg8-dev \ - libpng-dev \ - software-properties-common -RUN add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" && apt update && apt install -y \ - libjasper1 \ - libtiff-dev \ - libavcodec-dev \ - libavformat-dev \ - libswscale-dev \ - libdc1394-22-dev \ - libxine2-dev \ - libv4l-dev - -RUN cd /usr/include/linux -RUN ln -s -f ../libv4l1-videodev.h videodev.h -RUN cd ~ -RUN apt install -y \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ - libgtk2.0-dev libtbb-dev qt5-default \ - libatlas-base-dev \ - libfaac-dev \ - libmp3lame-dev \ - libtheora-dev \ - libvorbis-dev \ - libxvidcore-dev \ - libopencore-amrnb-dev \ - libopencore-amrwb-dev \ - libavresample-dev \ - x264 \ - v4l-utils - -# Setup OpenCV source -RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ - unzip ${OPENCV_VERSION}.zip && \ - rm ${OPENCV_VERSION}.zip && \ - mv opencv-${OPENCV_VERSION} opencv - -# Setup opencv-contrib Source -RUN wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ - unzip ${OPENCV_VERSION}.zip && \ - rm ${OPENCV_VERSION}.zip && \ - mv opencv_contrib-${OPENCV_VERSION} opencv_contrib - -# Build OpenCV -RUN cd opencv && mkdir build && cd build && \ - cmake \ - -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ - -D CMAKE_BUILD_TYPE=RELEASE \ - -D BUILD_EXAMPLES=OFF \ - -D BUILD_DOCS=OFF \ - -D BUILD_PERF_TESTS=OFF \ - -D BUILD_TESTS=OFF \ - -D BUILD_opencv_java=OFF \ - -D BUILD_opencv_python=OFF \ - .. && make -j4 && make install && ldconfig - -WORKDIR / - -# Download OpenCvSharp -RUN git clone https://github.com/shimat/opencvsharp.git -RUN cd opencvsharp && git fetch --all --tags --prune #&& git checkout ${OPENCVSHARP_VERSION} - -# Install the Extern lib. -WORKDIR /opencvsharp/src -RUN mkdir /opencvsharp/make -RUN cd /opencvsharp/make && cmake -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && make -j4 && make install -RUN ls /opencvsharp/make - - - - -FROM microsoft/dotnet:2.1-sdk AS build-dotnet-env -COPY --from=build-native-env /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so ./ -RUN git clone https://github.com/shimat/opencvsharp.git -RUN pwd -RUN ls - -# Install Build the C# part of OpenCvSharp -WORKDIR /opencvsharp/src/OpenCvSharp -RUN cd /opencvsharp/src/OpenCvSharp && dotnet restore -RUN dotnet build -c Release -f netstandard2.0 - -WORKDIR /opencvsharp/src/OpenCvSharp.Blob -RUN cd /opencvsharp/src/OpenCvSharp.Blob && dotnet restore -RUN dotnet build -c Release -f netstandard2.0 - -WORKDIR /opencvsharp/src/OpenCvSharp.Extensions -RUN cd /opencvsharp/src/OpenCvSharp.Extensions && dotnet restore -RUN dotnet build -c Release -f netstandard2.0 - -RUN mkdir /opencvsharp/build -WORKDIR /opencvsharp/build -RUN cp /libOpenCvSharpExtern.so . -RUN cp /opencvsharp/src/OpenCvSharp/bin/Release/netstandard2.0/* . -RUN cp /opencvsharp/src/OpenCvSharp.Blob/bin/Release/netstandard2.0/* . -RUN cp /opencvsharp/src/OpenCvSharp.Extensions/bin/Release/netstandard2.0/* . -RUN pwd -RUN ls - - - - - -FROM microsoft/dotnet:2.2-runtime -WORKDIR /app -COPY --from=build-dotnet-env /opencvsharp/build ./ -RUN pwd -RUN ls -#ENTRYPOINT ["ls"] \ No newline at end of file diff --git a/LICENSE b/LICENSE index 5082cdacd..434e92781 100644 --- a/LICENSE +++ b/LICENSE @@ -1,29 +1,201 @@ -BSD 3-Clause License - -Copyright (c) 2019, shimat -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + 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 2008 shimat + + 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/OpenCvSharp.shfbproj b/OpenCvSharp.shfbproj deleted file mode 100644 index 185e44690..000000000 --- a/OpenCvSharp.shfbproj +++ /dev/null @@ -1,82 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {5cbd22b4-2d40-4629-9138-cf3dd157ee3e} - 2015.6.5.0 - - Documentation - Documentation - Documentation - - .NET Framework 4.6 - .\Help\ - Documentation - en-US - OnlyWarningsAndErrors - Website - False - True - False - True - AutoDocumentCtors, AutoDocumentDispose - - - - - - - - - - - 1.0.0.0 - 2 - False - C#, Visual Basic, Managed C++, F#, JavaScript - Blank - True - VS2013 - False - Guid - A Sandcastle Documented Class Library - AboveNamespaces - 100 - Attributes, ExplicitInterfaceImplementations, InheritedMembers, InheritedFrameworkMembers, Protected, ProtectedInternalAsProtected - Msdn - True - - - - - - - - - - - - - - - - - - - - - - - - - - - OnBuildSuccess - - \ No newline at end of file diff --git a/OpenCvSharp.sln b/OpenCvSharp.sln index 291774a0c..73ba676ab 100644 --- a/OpenCvSharp.sln +++ b/OpenCvSharp.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26906.1 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E048D213-B3B9-453F-9A41-29FDEB0D496B}" EndProject @@ -14,195 +14,198 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp", "src\OpenCvSh EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp.Tests", "test\OpenCvSharp.Tests\OpenCvSharp.Tests.csproj", "{FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp.Blob", "src\OpenCvSharp.Blob\OpenCvSharp.Blob.csproj", "{82AFDA65-515E-4EC0-A415-77D8A6711508}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp.Extensions", "src\OpenCvSharp.Extensions\OpenCvSharp.Extensions.csproj", "{B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp.UserInterface", "src\OpenCvSharp.UserInterface\OpenCvSharp.UserInterface.csproj", "{FAD73716-92EC-4A0F-B594-286FF08EDE33}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenCvSharpExtern", "src\OpenCvSharpExtern\OpenCvSharpExtern.vcxproj", "{8E7279F8-F801-4672-B42F-1ED2C68B16A4}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.DebuggerVisualizers", "src\OpenCvSharp.DebuggerVisualizers\OpenCvSharp.DebuggerVisualizers.csproj", "{4232CB4A-DFE3-46CA-9503-C5F1798BAED3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tool", "tool", "{A6E578C0-A34A-4CCF-A808-CBAC81CB48C0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.ReleaseMaker", "tool\OpenCvSharp.ReleaseMaker\OpenCvSharp.ReleaseMaker.csproj", "{E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp.NupkgBetaRemover", "tool\OpenCvSharp.NupkgBetaRemover\OpenCvSharp.NupkgBetaRemover.csproj", "{CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp.WpfExtensions", "src\OpenCvSharp.WpfExtensions\OpenCvSharp.WpfExtensions.csproj", "{01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp.ReleaseMaker", "tool\OpenCvSharp.ReleaseMaker\OpenCvSharp.ReleaseMaker.csproj", "{1C399497-5240-439A-879A-4ACB34C409AE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{47A5316C-49F2-402A-A04C-0A0AAA397F47}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.DebuggerVisualizers.Tester", "test\OpenCvSharp.DebuggerVisualizers.Tester\OpenCvSharp.DebuggerVisualizers.Tester.csproj", "{FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCvSharp.NupkgBetaRemover", "tool\OpenCvSharp.NupkgBetaRemover\OpenCvSharp.NupkgBetaRemover.csproj", "{CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCvSharp.Tests.Windows", "test\OpenCvSharp.Tests.Windows\OpenCvSharp.Tests.Windows.csproj", "{36F6A125-3633-441E-9794-97EB91E50F20}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM Release|x64 = Release|x64 Release|x86 = Release|x86 - Release-JP|Any CPU = Release-JP|Any CPU - Release-JP|x64 = Release-JP|x64 - Release-JP|x86 = Release-JP|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {EB310923-197F-4E20-B123-3A3E7F1D5069}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB310923-197F-4E20-B123-3A3E7F1D5069}.Debug|ARM.ActiveCfg = Debug|Any CPU + {EB310923-197F-4E20-B123-3A3E7F1D5069}.Debug|ARM.Build.0 = Debug|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Debug|x64.ActiveCfg = Debug|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Debug|x64.Build.0 = Debug|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Debug|x86.ActiveCfg = Debug|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Debug|x86.Build.0 = Debug|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release|Any CPU.ActiveCfg = Release|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release|Any CPU.Build.0 = Release|Any CPU + {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release|ARM.ActiveCfg = Release|Any CPU + {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release|ARM.Build.0 = Release|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release|x64.ActiveCfg = Release|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release|x64.Build.0 = Release|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release|x86.ActiveCfg = Release|Any CPU {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release|x86.Build.0 = Release|Any CPU - {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release-JP|Any CPU.ActiveCfg = Release|Any CPU - {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release-JP|Any CPU.Build.0 = Release|Any CPU - {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release-JP|x64.ActiveCfg = Release-JP|Any CPU - {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release-JP|x64.Build.0 = Release-JP|Any CPU - {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release-JP|x86.ActiveCfg = Release-JP|Any CPU - {EB310923-197F-4E20-B123-3A3E7F1D5069}.Release-JP|x86.Build.0 = Release-JP|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Debug|ARM.ActiveCfg = Debug|Any CPU + {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Debug|ARM.Build.0 = Debug|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Debug|x64.ActiveCfg = Debug|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Debug|x64.Build.0 = Debug|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Debug|x86.ActiveCfg = Debug|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Debug|x86.Build.0 = Debug|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release|Any CPU.ActiveCfg = Release|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release|Any CPU.Build.0 = Release|Any CPU + {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release|ARM.ActiveCfg = Release|Any CPU + {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release|ARM.Build.0 = Release|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release|x64.ActiveCfg = Release|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release|x64.Build.0 = Release|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release|x86.ActiveCfg = Release|Any CPU {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release|x86.Build.0 = Release|Any CPU - {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release-JP|Any CPU.ActiveCfg = Release|Any CPU - {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release-JP|Any CPU.Build.0 = Release|Any CPU - {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release-JP|x64.ActiveCfg = Release|Any CPU - {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release-JP|x64.Build.0 = Release|Any CPU - {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release-JP|x86.ActiveCfg = Release|Any CPU - {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E}.Release-JP|x86.Build.0 = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Debug|Any CPU.Build.0 = Debug|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Debug|x64.ActiveCfg = Debug|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Debug|x64.Build.0 = Debug|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Debug|x86.ActiveCfg = Debug|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Debug|x86.Build.0 = Debug|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release|Any CPU.ActiveCfg = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release|Any CPU.Build.0 = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release|x64.ActiveCfg = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release|x64.Build.0 = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release|x86.ActiveCfg = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release|x86.Build.0 = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release-JP|Any CPU.ActiveCfg = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release-JP|Any CPU.Build.0 = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release-JP|x64.ActiveCfg = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release-JP|x64.Build.0 = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release-JP|x86.ActiveCfg = Release|Any CPU - {82AFDA65-515E-4EC0-A415-77D8A6711508}.Release-JP|x86.Build.0 = Release|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Debug|ARM.ActiveCfg = Debug|Any CPU + {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Debug|ARM.Build.0 = Debug|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Debug|x64.ActiveCfg = Debug|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Debug|x64.Build.0 = Debug|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Debug|x86.ActiveCfg = Debug|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Debug|x86.Build.0 = Debug|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release|Any CPU.ActiveCfg = Release|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release|Any CPU.Build.0 = Release|Any CPU + {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release|ARM.ActiveCfg = Release|Any CPU + {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release|ARM.Build.0 = Release|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release|x64.ActiveCfg = Release|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release|x64.Build.0 = Release|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release|x86.ActiveCfg = Release|Any CPU {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release|x86.Build.0 = Release|Any CPU - {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release-JP|Any CPU.ActiveCfg = Release|Any CPU - {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release-JP|Any CPU.Build.0 = Release|Any CPU - {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release-JP|x64.ActiveCfg = Release|Any CPU - {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release-JP|x64.Build.0 = Release|Any CPU - {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release-JP|x86.ActiveCfg = Release|Any CPU - {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00}.Release-JP|x86.Build.0 = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Debug|x64.ActiveCfg = Debug|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Debug|x64.Build.0 = Debug|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Debug|x86.ActiveCfg = Debug|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Debug|x86.Build.0 = Debug|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release|Any CPU.Build.0 = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release|x64.ActiveCfg = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release|x64.Build.0 = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release|x86.ActiveCfg = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release|x86.Build.0 = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release-JP|Any CPU.ActiveCfg = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release-JP|Any CPU.Build.0 = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release-JP|x64.ActiveCfg = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release-JP|x64.Build.0 = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release-JP|x86.ActiveCfg = Release|Any CPU - {FAD73716-92EC-4A0F-B594-286FF08EDE33}.Release-JP|x86.Build.0 = Release|Any CPU {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Debug|ARM.ActiveCfg = Debug|Win32 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Debug|x64.ActiveCfg = Release|x64 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Debug|x64.Build.0 = Release|x64 - {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Debug|x86.ActiveCfg = Debug|Win32 + {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Debug|x86.ActiveCfg = Release|Win32 + {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Debug|x86.Build.0 = Release|Win32 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|Any CPU.ActiveCfg = Release|x64 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|Any CPU.Build.0 = Release|x64 + {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|ARM.ActiveCfg = Release|Win32 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|x64.ActiveCfg = Release|x64 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|x64.Build.0 = Release|x64 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|x86.ActiveCfg = Release|Win32 {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release|x86.Build.0 = Release|Win32 - {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release-JP|Any CPU.ActiveCfg = Release|x64 - {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release-JP|Any CPU.Build.0 = Release|x64 - {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release-JP|x64.ActiveCfg = Release|x64 - {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release-JP|x64.Build.0 = Release|x64 - {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release-JP|x86.ActiveCfg = Release|Win32 - {8E7279F8-F801-4672-B42F-1ED2C68B16A4}.Release-JP|x86.Build.0 = Release|Win32 {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Debug|ARM.ActiveCfg = Debug|Any CPU + {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Debug|ARM.Build.0 = Debug|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Debug|x64.ActiveCfg = Debug|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Debug|x64.Build.0 = Debug|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Debug|x86.ActiveCfg = Debug|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Debug|x86.Build.0 = Debug|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release|Any CPU.ActiveCfg = Release|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release|Any CPU.Build.0 = Release|Any CPU + {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release|ARM.ActiveCfg = Release|Any CPU + {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release|ARM.Build.0 = Release|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release|x64.ActiveCfg = Release|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release|x64.Build.0 = Release|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release|x86.ActiveCfg = Release|Any CPU {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release|x86.Build.0 = Release|Any CPU - {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release-JP|Any CPU.ActiveCfg = Release|Any CPU - {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release-JP|Any CPU.Build.0 = Release|Any CPU - {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release-JP|x64.ActiveCfg = Release|Any CPU - {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release-JP|x64.Build.0 = Release|Any CPU - {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release-JP|x86.ActiveCfg = Release|Any CPU - {4232CB4A-DFE3-46CA-9503-C5F1798BAED3}.Release-JP|x86.Build.0 = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Debug|x64.ActiveCfg = Debug|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Debug|x64.Build.0 = Debug|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Debug|x86.ActiveCfg = Debug|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Debug|x86.Build.0 = Debug|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release|Any CPU.Build.0 = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release|x64.ActiveCfg = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release|x64.Build.0 = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release|x86.ActiveCfg = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release|x86.Build.0 = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release-JP|Any CPU.ActiveCfg = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release-JP|Any CPU.Build.0 = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release-JP|x64.ActiveCfg = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release-JP|x64.Build.0 = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release-JP|x86.ActiveCfg = Release|Any CPU - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23}.Release-JP|x86.Build.0 = Release|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Debug|ARM.ActiveCfg = Debug|Any CPU + {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Debug|ARM.Build.0 = Debug|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Debug|x64.ActiveCfg = Debug|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Debug|x64.Build.0 = Debug|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Debug|x86.ActiveCfg = Debug|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Debug|x86.Build.0 = Debug|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release|Any CPU.ActiveCfg = Release|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release|Any CPU.Build.0 = Release|Any CPU + {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release|ARM.ActiveCfg = Release|Any CPU + {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release|ARM.Build.0 = Release|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release|x64.ActiveCfg = Release|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release|x64.Build.0 = Release|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release|x86.ActiveCfg = Release|Any CPU {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release|x86.Build.0 = Release|Any CPU - {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release-JP|Any CPU.ActiveCfg = Release|Any CPU - {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release-JP|Any CPU.Build.0 = Release|Any CPU - {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release-JP|x64.ActiveCfg = Release|Any CPU - {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release-JP|x64.Build.0 = Release|Any CPU - {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release-JP|x86.ActiveCfg = Release|Any CPU - {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A}.Release-JP|x86.Build.0 = Release|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Debug|ARM.ActiveCfg = Debug|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Debug|ARM.Build.0 = Debug|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Debug|x64.ActiveCfg = Debug|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Debug|x64.Build.0 = Debug|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Debug|x86.ActiveCfg = Debug|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Debug|x86.Build.0 = Debug|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Release|Any CPU.Build.0 = Release|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Release|ARM.ActiveCfg = Release|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Release|ARM.Build.0 = Release|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Release|x64.ActiveCfg = Release|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Release|x64.Build.0 = Release|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Release|x86.ActiveCfg = Release|Any CPU + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5}.Release|x86.Build.0 = Release|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Debug|ARM.ActiveCfg = Debug|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Debug|ARM.Build.0 = Debug|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Debug|x64.ActiveCfg = Debug|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Debug|x64.Build.0 = Debug|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Debug|x86.ActiveCfg = Debug|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Debug|x86.Build.0 = Debug|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Release|Any CPU.Build.0 = Release|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Release|ARM.ActiveCfg = Release|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Release|ARM.Build.0 = Release|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Release|x64.ActiveCfg = Release|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Release|x64.Build.0 = Release|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Release|x86.ActiveCfg = Release|Any CPU + {1C399497-5240-439A-879A-4ACB34C409AE}.Release|x86.Build.0 = Release|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Debug|ARM.ActiveCfg = Debug|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Debug|ARM.Build.0 = Debug|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Debug|x64.ActiveCfg = Debug|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Debug|x64.Build.0 = Debug|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Debug|x86.ActiveCfg = Debug|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Debug|x86.Build.0 = Debug|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Release|Any CPU.Build.0 = Release|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Release|ARM.ActiveCfg = Release|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Release|ARM.Build.0 = Release|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Release|x64.ActiveCfg = Release|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Release|x64.Build.0 = Release|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Release|x86.ActiveCfg = Release|Any CPU + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC}.Release|x86.Build.0 = Release|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Debug|ARM.ActiveCfg = Debug|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Debug|ARM.Build.0 = Debug|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Debug|x64.ActiveCfg = Debug|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Debug|x64.Build.0 = Debug|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Debug|x86.ActiveCfg = Debug|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Debug|x86.Build.0 = Debug|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Release|Any CPU.Build.0 = Release|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Release|ARM.ActiveCfg = Release|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Release|ARM.Build.0 = Release|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Release|x64.ActiveCfg = Release|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Release|x64.Build.0 = Release|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Release|x86.ActiveCfg = Release|Any CPU + {36F6A125-3633-441E-9794-97EB91E50F20}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -210,13 +213,14 @@ Global GlobalSection(NestedProjects) = preSolution {EB310923-197F-4E20-B123-3A3E7F1D5069} = {E048D213-B3B9-453F-9A41-29FDEB0D496B} {FFBBCF99-97F0-4F81-AAF6-8D851A8E1D2E} = {1F113DD0-E292-47A5-8EFF-3FB5D0869BF3} - {82AFDA65-515E-4EC0-A415-77D8A6711508} = {E048D213-B3B9-453F-9A41-29FDEB0D496B} {B4B78BB2-1B7C-4CF2-BC72-43789EEDCE00} = {E048D213-B3B9-453F-9A41-29FDEB0D496B} - {FAD73716-92EC-4A0F-B594-286FF08EDE33} = {E048D213-B3B9-453F-9A41-29FDEB0D496B} {8E7279F8-F801-4672-B42F-1ED2C68B16A4} = {E048D213-B3B9-453F-9A41-29FDEB0D496B} {4232CB4A-DFE3-46CA-9503-C5F1798BAED3} = {E048D213-B3B9-453F-9A41-29FDEB0D496B} - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23} = {A6E578C0-A34A-4CCF-A808-CBAC81CB48C0} {CC19F9A5-01A7-4BDF-B34C-CF56F46A474A} = {A6E578C0-A34A-4CCF-A808-CBAC81CB48C0} + {01FD66CE-F81A-4641-BE30-3CF9DE84D6D5} = {E048D213-B3B9-453F-9A41-29FDEB0D496B} + {1C399497-5240-439A-879A-4ACB34C409AE} = {A6E578C0-A34A-4CCF-A808-CBAC81CB48C0} + {FFD602AA-0A08-40DD-8ACD-7F5A3BA51DEC} = {1F113DD0-E292-47A5-8EFF-3FB5D0869BF3} + {36F6A125-3633-441E-9794-97EB91E50F20} = {1F113DD0-E292-47A5-8EFF-3FB5D0869BF3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {60DD551B-ED40-447E-AABE-B408178D29D1} diff --git a/OpenCvSharp.sln.DotSettings b/OpenCvSharp.sln.DotSettings index 715590096..63d9a7751 100644 --- a/OpenCvSharp.sln.DotSettings +++ b/OpenCvSharp.sln.DotSettings @@ -1,37 +1,159 @@  <NamingElement Priority="6"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="local variable" /></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></NamingElement> <NamingElement Priority="5"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="parameter" /></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></NamingElement> + LTRB + LUT + PCA + QR RB + RNG SURF + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + True + True + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + True True + True + True + + + True + True + True + True + True True True True True + True + True + True + True + True True + True + True True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True True + True + True + True True + True + True True + True + True + True + + True + True + True + True True True + True + True + True + True True + True + True + True + True + True + True + True + True + True True + True + True + True + True + True + True + True + True + True + True True True + True + True True + True + True + True + True + True + True True True True + True True + True True True + True + True + + + True + True + True + True + True + True + True + True + True + True + True + True True + True + True + True True + True True + True + True + True + True + True - True \ No newline at end of file + True + True + True + True diff --git a/README.md b/README.md index 9f2d34925..0ebba09c2 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,51 @@ -# OpenCvSharp [![Build status](https://ci.appveyor.com/api/projects/status/dvjexft02s6b3re6/branch/master?svg=true)](https://ci.appveyor.com/project/shimat/opencvsharp/branch/master) [![GitHub license](https://img.shields.io/github/license/shimat/opencvsharp.svg)](https://github.com/shimat/opencvsharp/blob/master/LICENSE) +![opencvsharp](https://socialify.git.ci/shimat/opencvsharp/image?description=1&forks=1&language=1&owner=1&pattern=Plus&stargazers=1&theme=Light) -Cross platform wrapper of OpenCV for .NET Framework. +[![Github Actions Windows Status](https://github.com/shimat/opencvsharp/workflows/Windows%20Server%202022/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions Ubuntu Status](https://github.com/shimat/opencvsharp/workflows/Ubuntu%2022.04/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![GitHub license](https://img.shields.io/github/license/shimat/opencvsharp.svg)](https://github.com/shimat/opencvsharp/blob/master/LICENSE) -Old versions of OpenCvSharp are maintained in [opencvsharp_2410](https://github.com/shimat/opencvsharp_2410). +Old versions of OpenCvSharp are stored in [opencvsharp_2410](https://github.com/shimat/opencvsharp_2410). -## Installation -### NuGet +## NuGet +### Managed libraries | Package | Description | Link | |---------|-------------|------| |**OpenCvSharp4**| OpenCvSharp core libraries | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.svg)](https://badge.fury.io/nu/OpenCvSharp4) | -|**OpenCvSharp4.Windows**| All-in-one package for Windows - same as [OpenCvSharp3-AnyCPU](https://www.nuget.org/packages/OpenCvSharp3-AnyCPU/) | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.Windows.svg)](https://badge.fury.io/nu/OpenCvSharp4.Windows) | -|**OpenCvSharp4.runtime.win**| Native bindings for Windows x64/x86 | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.runtime.win.svg)](https://badge.fury.io/nu/OpenCvSharp4.runtime.win) | -|**OpenCvSharp4.runtime.ubuntu.18.04-x64**| Native bindings for Ubuntu 18.04 x64 | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.runtime.ubuntu.18.04-x64.svg)](https://badge.fury.io/nu/OpenCvSharp4.runtime.ubuntu.18.04-x64) | -|(beta packages)| Development Build Package | https://ci.appveyor.com/nuget/opencvsharp | +|**OpenCvSharp4.Extensions**| GDI+ Extensions | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.Extensions.svg)](https://badge.fury.io/nu/OpenCvSharp4.Extensions) | +|**OpenCvSharp4.WpfExtensions**| WPF Extensions | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.WpfExtensions.svg)](https://badge.fury.io/nu/OpenCvSharp4.WpfExtensions) | +|**OpenCvSharp4.Windows**| All-in-one package for Windows (except UWP) | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.Windows.svg)](https://badge.fury.io/nu/OpenCvSharp4.Windows) | + +### Native bindings +| Package | Description | Link | +|---------|-------------|------| +|**OpenCvSharp4.runtime.win**| Native bindings for Windows x64/x86 (except UWP) | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.runtime.win.svg)](https://badge.fury.io/nu/OpenCvSharp4.runtime.win) | +|**OpenCvSharp4.runtime.uwp**| Native bindings for UWP (Universal Windows Platform) x64/x86/ARM | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.runtime.uwp.svg)](https://badge.fury.io/nu/OpenCvSharp4.runtime.uwp) | +|**OpenCvSharp4.official.runtime.linux-x64**| Native bindings for Linux x64 | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.official.runtime.linux-x64.svg)](https://badge.fury.io/nu/OpenCvSharp4.official.runtime.linux-x64) | +|**OpenCvSharp4.runtime.linux-arm**| Native bindings for Linux Arm | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.runtime.linux-arm.svg)](https://www.nuget.org/packages/OpenCvSharp4.runtime.linux-arm/) | +|**OpenCvSharp4.runtime.wasm**| Native bindings for WebAssembly | [![NuGet version](https://badge.fury.io/nu/OpenCvSharp4.runtime.wasm.svg)](https://www.nuget.org/packages/OpenCvSharp4.runtime.wasm/) | -Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so) is required to work OpenCvSharp. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows and Ubuntu 18.04 are released. +Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so) is required to work OpenCvSharp. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows, UWP and Ubuntu are released. Packages named OpenCvSharp3-* and OpenCvSharp-* are deprecated. -- [OpenCvSharp3-AnyCPU](https://www.nuget.org/packages/OpenCvSharp3-AnyCPU/) -- [OpenCvSharp3-WithoutDll](https://www.nuget.org/packages/OpenCvSharp3-WithoutDll/) -- [OpenCvSharp-AnyCPU](https://www.nuget.org/packages/OpenCvSharp-AnyCPU/) -- [OpenCvSharp-WithoutDll](https://www.nuget.org/packages/OpenCvSharp-WithoutDll/) +> [OpenCvSharp3-AnyCPU](https://www.nuget.org/packages/OpenCvSharp3-AnyCPU/) / [OpenCvSharp3-WithoutDll](https://www.nuget.org/packages/OpenCvSharp3-WithoutDll/) / [OpenCvSharp-AnyCPU](https://www.nuget.org/packages/OpenCvSharp-AnyCPU/) / [OpenCvSharp-WithoutDll](https://www.nuget.org/packages/OpenCvSharp-WithoutDll/) -### Windows +## Docker images +https://github.com/shimat?tab=packages + +## Installation + +### Windows (except UWP) Add `OpenCvSharp4` and `OpenCvSharp4.runtime.win` NuGet packages to your project. You can use `OpenCvSharp4.Windows` instead. -### Ubuntu 18.04 -Add `OpenCvSharp4` and `OpenCvSharp4.runtime.ubuntu.18.04.x64` NuGet packages to your project +### UWP +Add `OpenCvSharp4` and `OpenCvSharp4.runtime.uwp` NuGet packages to your project. Note that `OpenCvSharp4.runtime.win` and `OpenCvSharp4.Windows` don't work for UWP. + +### Ubuntu 22.04 +Add `OpenCvSharp4` and `OpenCvSharp4.runtime.ubuntu.22.04.x64` NuGet packages to your project. ``` dotnet new console -n ConsoleApp01 cd ConsoleApp01 dotnet add package OpenCvSharp4 -dotnet add package OpenCvSharp4.runtime.ubuntu.18.04-x64 +dotnet add package OpenCvSharp4_.runtime.ubuntu.22.04-x64 # -- edit Program.cs --- # dotnet run ``` @@ -40,20 +53,30 @@ dotnet run ### Downloads If you do not use NuGet, get DLL files from the [release page](https://github.com/shimat/opencvsharp/releases). +## Target OpenCV +* [OpenCV 4.10.0](http://opencv.org/) with [opencv_contrib](https://github.com/opencv/opencv_contrib) + ## Requirements -* [OpenCV 4.1.0](http://opencv.org/) with [opencv_contrib](https://github.com/opencv/opencv_contrib) -* (Windows)[Visual C++ 2017 Redistributable Package](https://go.microsoft.com/fwlink/?LinkId=746572) -* [.NET Framework 2.0](http://www.microsoft.com/ja-jp/download/details.aspx?id=1639) or later / [.NET Core 2.0](https://www.microsoft.com/net/download) / [Mono](http://www.mono-project.com/Main_Page) +* [.NET Framework 4.8](http://www.microsoft.com/ja-jp/download/details.aspx?id=1639) / [.NET 6](https://www.microsoft.com/net/download) or later / .NET Standard 2.0 +* (Windows) [Visual C++ 2022 Redistributable Package](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) +* (Windows Server) Media Foundation +``` +PS1> Install-WindowsFeature Server-Media-Foundation +``` +* (Ubuntu) You must pre-install all the dependency packages needed to build OpenCV. Many packages such as libjpeg must be installed in order to work OpenCV. +https://www.learnopencv.com/install-opencv-4-on-ubuntu-18-04/ + -OpenCvSharp may not work on UWP and Unity platform. Please consider using [OpenCV for Unity](https://www.assetstore.unity3d.com/en/#!/content/21088) +**OpenCvSharp won't work on Unity and Xamarin platform.** For Unity, please consider using [OpenCV for Unity](https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088) or some other solutions. -## Documents -https://shimat.github.io/opencvsharp_docs/index.html +**OpenCvSharp does not support CUDA.** If you want to use the CUDA features, you need to customize the native bindings yourself. ## Usage For more details, see **[samples](https://github.com/shimat/opencvsharp_samples/)** and **[Wiki](https://github.com/shimat/opencvsharp/wiki)** pages. +**Always remember to release Mat instances! The `using` syntax is useful.** ```C# +// C# 8 // Edge detection by Canny algorithm using OpenCvSharp; @@ -61,9 +84,8 @@ class Program { static void Main() { - Mat src = new Mat("lenna.png", ImreadModes.Grayscale); -        // Mat src = Cv2.ImRead("lenna.png", ImreadModes.Grayscale); -        Mat dst = new Mat(); + using var src = new Mat("lenna.png", ImreadModes.Grayscale); +        using var dst = new Mat(); Cv2.Canny(src, dst, 50, 200); using (new Window("src image", src)) @@ -75,29 +97,67 @@ class Program } ``` +As mentioned above, objects of classes, such as Mat and MatExpr, have unmanaged resources and need to be manually released by calling the Dispose() method. Worst of all, the +, -, *, and other operators create new objects each time, and these objects need to be disposed, or there will be memory leaks. Despite having the using syntax, the code still looks very verbose. + +Therefore, a ResourcesTracker class is provided. The ResourcesTracker implements the IDisposable interface, and when the Dispose() method is called, all resources tracked by the ResourcesTracker are disposed. The T() method of ResourcesTracker can trace an object or an array of objects, and the method NewMat() is like T(new Mat(...). All the objects that need to be released can be wrapped with T().For example: t.T(255 - t.T(picMat * 0.8)) . Example code is as following: + +```csharp +using (var t = new ResourcesTracker()) +{ + Mat mat1 = t.NewMat(new Size(100, 100), MatType.CV_8UC3, new Scalar(0)); + Mat mat3 = t.T(255-t.T(mat1*0.8)); + Mat[] mats1 = t.T(mat3.Split()); + Mat mat4 = t.NewMat(); + Cv2.Merge(new Mat[] { mats1[0], mats1[1], mats1[2] }, mat4); +} + +using (var t = new ResourcesTracker()) +{ + var src = t.T(new Mat(@"lenna.png", ImreadModes.Grayscale)); + var dst = t.NewMat(); + Cv2.Canny(src, dst, 50, 200); + var blurredDst = t.T(dst.Blur(new Size(3, 3))); + t.T(new Window("src image", src)); + t.T(new Window("dst image", blurredDst)); + Cv2.WaitKey(); +} +``` + + ## Features * OpenCvSharp is modeled on the native OpenCV C/C++ API style as much as possible. * Many classes of OpenCvSharp implement IDisposable. There is no need to manage unsafe resources. * OpenCvSharp does not force object-oriented programming style on you. You can also call native-style OpenCV functions. -* OpenCvSharp provides functions for converting from Mat/IplImage into Bitmap(GDI+) or WriteableBitmap(WPF). -* OpenCvSharp can work on [Mono](http://www.mono-project.com/Main_Page). It can run on any platform which [Mono](http://www.mono-project.com/Main_Page) supports (e.g. Linux). +* OpenCvSharp provides functions for converting from `Mat` into `Bitmap`(GDI+) or `WriteableBitmap`(WPF). + +## Code samples +https://github.com/shimat/opencvsharp_samples/ + +## API Documents +http://shimat.github.io/opencvsharp/api/OpenCvSharp.html ## OpenCvSharp Build Instructions ### Windows -- Install Visual Studio 2017 or later +- Install Visual Studio 2022 or later - VC++ features are required. -- Get all submodules +- Run `download_opencv_windows.ps1` to download OpenCV libs and headers from https://github.com/shimat/opencv_files. Those lib files are precompiled by the owner of OpenCvSharp using GitHub Actions. ``` -git submodule update --init --recursive +.\download_opencv_windows.ps1 ``` - Build OpenCvSharp - Open `OpenCvSharp.sln` and build + +#### How to customize OpenCV binaries yourself +If you want to use some OpenCV features that are not provided by default in OpenCvSharp (e.g. GPU), you will have to build OpenCV yourself. The binary files of OpenCV for OpenCvSharp for Windows are created in the [opencv_files](https://github.com/shimat/opencv_files) repository. See the README. -### Ubuntu 18.04 +- `git clone --recursive https://github.com/shimat/opencv_files` +- Edit `build_windows.ps1` or `build_uwp.ps1` to customize the CMake parameters . +- Run the PowerShell script. +### Ubuntu - Build OpenCV with opencv_contrib. - https://www.learnopencv.com/install-opencv-4-on-ubuntu-18-04/ -- Install .NET Core SDK. https://dotnet.microsoft.com/download/linux-package-manager/ubuntu18-04/sdk-2.1.202 +- Install .NET Core SDK. https://learn.microsoft.com/ja-jp/dotnet/core/install/linux-ubuntu - Get OpenCvSharp source files ``` git clone https://github.com/shimat/opencvsharp.git @@ -128,19 +188,7 @@ dotnet add package OpenCvSharp4 dotnet run ``` -### Older Ubuntu -Refer to the [Dockerfile](https://github.com/shimat/opencvsharp/blob/master/Dockerfile) and [Wiki pages](https://github.com/shimat/opencvsharp/wiki). - -## License -Licensed under the [BSD 3-Clause License](https://github.com/shimat/opencvsharp/blob/master/LICENSE). - ## Donations - If you find the OpenCvSharp library useful and would like to show your gratitude by donating, here are some donation options. Thank you. -Type | Address ------- | ------- -**BTC** (Bitcoin) | 3EWhyNe3xzNNrbUgk4nXAVEkaWdpGncotc -**BCH** (Bitcoin Cash) | 3EWhyNe3xzNNrbUgk4nXAVEkaWdpGncotc -**ETH** (Ethereum) | 0x8a6089d60812ec88822d81bc6c65ba4ae63ea269 -**LTC** (Litecoin) | LLpmBjjVGZf93MEohEZpkADMpnyqAS3iQC +https://github.com/sponsors/shimat diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index c78d36032..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,197 +0,0 @@ -version: '4.1.0-{build}' - -#environment: -# APPVEYOR_SAVE_CACHE_ON_ERROR: false -# VCPKG_BUILD_TYPE: Release - -init: -- ps: | - Write-Host "APPVEYOR_BUILD_VERSION = "$env:APPVEYOR_BUILD_VERSION - if ($isWindows) { - $version = $env:APPVEYOR_BUILD_VERSION.Split('-')[0] - Write-Host "version = "$version - $date = Get-Date -Format "yyyyMMdd" - Update-AppveyorBuild -Version "$version.$date-beta-$env:APPVEYOR_BUILD_NUMBER" - Write-Host "APPVEYOR_BUILD_VERSION = "$env:APPVEYOR_BUILD_VERSION - } - iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - Write-Host "APPVEYOR = "$env:APPVEYOR - Write-Host "CI = "$env:CI - Write-Host "APPVEYOR_API_URL = "$env:APPVEYOR_API_URL - Write-Host "APPVEYOR_ACCOUNT_NAME = "$env:APPVEYOR_ACCOUNT_NAME - Write-Host "APPVEYOR_PROJECT_ID = "$env:APPVEYOR_PROJECT_ID - Write-Host "APPVEYOR_PROJECT_NAME = "$env:APPVEYOR_PROJECT_NAME - Write-Host "APPVEYOR_PROJECT_SLUG = "$env:APPVEYOR_PROJECT_SLUG - Write-Host "APPVEYOR_BUILD_FOLDER = "$env:APPVEYOR_BUILD_FOLDER - Write-Host "APPVEYOR_BUILD_ID = "$env:APPVEYOR_BUILD_ID - Write-Host "APPVEYOR_BUILD_NUMBER = "$env:APPVEYOR_BUILD_NUMBER - Write-Host "APPVEYOR_BUILD_VERSION = "$env:APPVEYOR_BUILD_VERSION - Write-Host "APPVEYOR_BUILD_WORKER_IMAGE = "$env:APPVEYOR_BUILD_WORKER_IMAGE - Write-Host "APPVEYOR_PULL_REQUEST_NUMBER = "$env:APPVEYOR_PULL_REQUEST_NUMBER - Write-Host "APPVEYOR_PULL_REQUEST_TITLE = "$env:APPVEYOR_PULL_REQUEST_TITLE - Write-Host "APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME = "$env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME - Write-Host "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH = "$env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH - Write-Host "APPVEYOR_PULL_REQUEST_HEAD_COMMIT = "$env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT - Write-Host "APPVEYOR_JOB_ID = "$env:APPVEYOR_JOB_ID - Write-Host "APPVEYOR_JOB_NAME = "$env:APPVEYOR_JOB_NAME - Write-Host "APPVEYOR_JOB_NUMBER = "$env:APPVEYOR_JOB_NUMBER - Write-Host "APPVEYOR_REPO_PROVIDER = "$env:APPVEYOR_REPO_PROVIDER - Write-Host "APPVEYOR_REPO_SCM = "$env:APPVEYOR_REPO_SCM - Write-Host "APPVEYOR_REPO_NAME = "$env:APPVEYOR_REPO_NAME - Write-Host "APPVEYOR_REPO_BRANCH = "$env:APPVEYOR_REPO_BRANCH - Write-Host "APPVEYOR_REPO_TAG = "$env:APPVEYOR_REPO_TAG - Write-Host "APPVEYOR_REPO_TAG_NAME = "$env:APPVEYOR_REPO_TAG_NAME - Write-Host "APPVEYOR_REPO_COMMIT = "$env:APPVEYOR_REPO_COMMIT - Write-Host "APPVEYOR_REPO_COMMIT_AUTHOR = "$env:APPVEYOR_REPO_COMMIT_AUTHOR - Write-Host "APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL = "$env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL - Write-Host "APPVEYOR_REPO_COMMIT_TIMESTAMP = "$env:APPVEYOR_REPO_COMMIT_TIMESTAMP - Write-Host "APPVEYOR_REPO_COMMIT_MESSAGE = "$env:APPVEYOR_REPO_COMMIT_MESSAGE - Write-Host "APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED = "$env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED - Write-Host "APPVEYOR_SCHEDULED_BUILD = "$env:APPVEYOR_SCHEDULED_BUILD - Write-Host "PLATFORM = "$env:PLATFORM - Write-Host "CONFIGURATION = "$env:CONFIGURATION - Write-Host "APPVEYOR_SAVE_CACHE_ON_ERROR = "$env:APPVEYOR_SAVE_CACHE_ON_ERROR - -#on_finish: -# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - -# Do not build feature branch with open Pull Requests -skip_branch_with_pr: true - -image: - - Ubuntu1804 - - Visual Studio 2019 - -configuration: Release - -#platform: -# - x64 -# - x86 - -#matrix: - #fast_finish: true - #exclude: - # - image: Ubuntu1804 - # platform: x86 - -cache: - #- c:\tools\vcpkg\installed\ - #- c:\tools\vcpkg\installed\ -> appveyor.yml - - packages -> **\packages.config - -install: -# update vcpkg -#- cd C:\Tools\vcpkg -#- git pull -#- .\bootstrap-vcpkg.bat -#- cd %APPVEYOR_BUILD_FOLDER% -# - cmd: cd c:\tools\vcpkg -# - cmd: vcpkg list -# - cmd: vcpkg integrate remove -# - cmd: SET VCPKG_BUILD_TYPE=release -# - cmd: vcpkg integrate install -# - cmd: if %PLATFORM% == x64 vcpkg install tesseract:x64-windows-static -# - cmd: if %PLATFORM% == x86 vcpkg install tesseract:x86-windows-static -# - cmd: cd %APPVEYOR_BUILD_FOLDER% -# - cmd: vcpkg list - - - sh: pwd - - sh: sudo apt update - - sh: sudo apt -y remove x264 libx264-dev - - sh: sudo apt -y install build-essential checkinstall cmake pkg-config yasm - - sh: sudo apt -y install git gfortran - - sh: sudo apt -y install libjpeg8-dev libpng-dev - - sh: sudo apt -y install software-properties-common - - sh: sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" - - sh: sudo apt -y update - - sh: sudo apt -y install libjasper1 - - sh: sudo apt -y install libtiff-dev - - sh: sudo apt -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev - - sh: sudo apt -y install libxine2-dev libv4l-dev - - sh: cd /usr/include/linux - - sh: sudo ln -s -f ../libv4l1-videodev.h videodev.h - - sh: cd $APPVEYOR_BUILD_FOLDER - - sh: sudo apt -y install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - - sh: sudo apt -y install libgtk2.0-dev libtbb-dev qt5-default - - sh: sudo apt -y install libatlas-base-dev - - sh: sudo apt -y install libfaac-dev libmp3lame-dev libtheora-dev - - sh: sudo apt -y install libvorbis-dev libxvidcore-dev - - sh: sudo apt -y install libopencore-amrnb-dev libopencore-amrwb-dev - - sh: sudo apt -y install libavresample-dev - - sh: sudo apt -y install x264 v4l-utils - - sh: sudo apt -y install libwebp-dev - - sh: sudo apt -y install tesseract-ocr libtesseract-dev libleptonica-dev - - sh: pwd; ls; - - sh: wget https://github.com/opencv/opencv/archive/4.1.0.zip -Oopencv-4.1.0.zip - - sh: wget https://github.com/opencv/opencv_contrib/archive/4.1.0.zip -Oopencv_contrib-4.1.0.zip - - sh: unzip opencv-4.1.0.zip - - sh: unzip opencv_contrib-4.1.0.zip - - sh: cd opencv-4.1.0 && mkdir build && cd build - - sh: cmake -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules -DENABLE_CXX11=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DCMAKE_INSTALL_PREFIX=${APPVEYOR_BUILD_FOLDER}/opencv_ubuntu .. - - sh: make -j2 - - sh: sudo make install - - sh: sudo ldconfig - - sh: cd ${APPVEYOR_BUILD_FOLDER} - - sh: pwd - - sh: ls - - sh: ls opencv_ubuntu - -before_build: - - cmd: git submodule update --init --recursive - - cmd: nuget restore - #- dotnet restore - -build_script: - - cmd: msbuild OpenCvSharp.sln /t:build /p:configuration=%CONFIGURATION% /p:platform=x64 -maxcpucount - - cmd: msbuild OpenCvSharp.sln /t:build /p:configuration=%CONFIGURATION% /p:platform=x86 -maxcpucount - - sh: mkdir src/build && cd $_ - - sh: cmake -D CMAKE_PREFIX_PATH=${APPVEYOR_BUILD_FOLDER}/opencv_ubuntu .. - - sh: make -j2 - - sh: pwd - - sh: ls - - sh: ls OpenCvSharpExtern - - sh: cp OpenCvSharpExtern/libOpenCvSharpExtern.so ${APPVEYOR_BUILD_FOLDER}/nuget/ - -after_build: -- ps: | - (Get-ChildItem $env:APPVEYOR_BUILD_FOLDER -Recurse).Where{ $_.Extension -eq ".nuspec" }.ForEach{ - [xml]$xml = Get-Content $_.FullName - $xml.package.metadata.version = $env:APPVEYOR_BUILD_VERSION - $xml.Save($_.FullName) - } - if ($isWindows) { - nuget pack nuget/OpenCvSharp4.nuspec -OutputDirectory artifacts - nuget pack nuget/OpenCvSharp4.Windows.nuspec -OutputDirectory artifacts - nuget pack nuget/OpenCvSharp4.runtime.win.nuspec -OutputDirectory artifacts - } else { - nuget pack $env:APPVEYOR_BUILD_FOLDER/nuget/OpenCvSharp4.runtime.ubuntu.18.04-x64.nuspec -OutputDirectory $env:APPVEYOR_BUILD_FOLDER/artifacts_ubuntu - } - -test_script: -- cmd: cd %APPVEYOR_BUILD_FOLDER% -- cmd: cd test -- cmd: cd OpenCvSharp.Tests -- cmd: dotnet test -c Release -f net472 #--no-build -- cmd: dotnet test -c Release -f netcoreapp2.1 #--no-build -- cmd: cd %APPVEYOR_BUILD_FOLDER% - -artifacts: - - path: artifacts\**\*.* - - path: artifacts_ubuntu/**/*.* - #- path: src/build/OpenCvSharpExtern - #- path: src\Release\x64\OpenCvSharpExtern.dll - #- path: src\Release\Win32\OpenCvSharpExtern.dll - -deploy: -- provider: NuGet # appveyor - server: https://ci.appveyor.com/nuget/shimat - api_key: - secure: PW0F7tbGr+QLuLPUGy+32pNtMZUJeqjyikz9nKlpALA= - skip_symbols: true - artifact: /.*\.nupkg/ - -#- provider: NuGet # nuget.org -# api_key: -# secure: qea/3lnas374qyS4Xw9t5Z5jBKsVsBPGsY938QHgJ2IQyrQmug0qPKDU7tll/QkJ -# skip_symbols: true -# artifact: /.*\.nupkg/ diff --git a/docfx/.gitignore b/docfx/.gitignore new file mode 100644 index 000000000..4378419e7 --- /dev/null +++ b/docfx/.gitignore @@ -0,0 +1,9 @@ +############### +# folder # +############### +/**/DROP/ +/**/TEMP/ +/**/packages/ +/**/bin/ +/**/obj/ +_site diff --git a/docfx/api/.gitignore b/docfx/api/.gitignore new file mode 100644 index 000000000..e8079a3be --- /dev/null +++ b/docfx/api/.gitignore @@ -0,0 +1,5 @@ +############### +# temp file # +############### +*.yml +.manifest diff --git a/docfx/api/index.md b/docfx/api/index.md new file mode 100644 index 000000000..eabc86fe1 --- /dev/null +++ b/docfx/api/index.md @@ -0,0 +1 @@ +# **[OpenCvSharp](https://github.com/shimat/opencvsharp) API Reference** diff --git a/docfx/articles/intro.md b/docfx/articles/intro.md new file mode 100644 index 000000000..c0478cede --- /dev/null +++ b/docfx/articles/intro.md @@ -0,0 +1 @@ +# Add your introductions here! diff --git a/docfx/articles/toc.yml b/docfx/articles/toc.yml new file mode 100644 index 000000000..ff89ef1fe --- /dev/null +++ b/docfx/articles/toc.yml @@ -0,0 +1,2 @@ +- name: Introduction + href: intro.md diff --git a/docfx/docfx.json b/docfx/docfx.json new file mode 100644 index 000000000..490f358a0 --- /dev/null +++ b/docfx/docfx.json @@ -0,0 +1,68 @@ +{ + "metadata": [ + { + "src": [ + { + "files": ["**/*.csproj"], + "exclude": [ "**/bin/**", "**/obj/**", "**/OpenCvSharp.DebuggerVisualizers/**" ], + "src": "../src" + } + ], + "dest": "api", + "disableGitFeatures": false, + "disableDefaultFilter": false, + "properties": { + "TargetFramework": "net6" + } + } + ], + "build": { + "content": [ + { + "files": [ + "api/**.yml", + "api/index.md" + ] + }, + { + "files": [ + "articles/**.md", + "articles/**/toc.yml", + "toc.yml", + "*.md", + "../*.md", + ] + } + ], + "resource": [ + { + "files": [ + "images/**" + ] + } + ], + "overwrite": [ + { + "files": [ + "apidoc/**.md" + ], + "exclude": [ + "obj/**", + "_site/**" + ] + } + ], + "dest": "_site", + "globalMetadataFiles": [], + "fileMetadataFiles": [], + "template": [ + "default" + ], + "postProcessors": [], + "markdownEngineName": "markdig", + "noLangKeyword": false, + "keepFileLink": false, + "cleanupCacheHistory": false, + "disableGitFeatures": false + } +} \ No newline at end of file diff --git a/docfx/index.md b/docfx/index.md new file mode 100644 index 000000000..eabc86fe1 --- /dev/null +++ b/docfx/index.md @@ -0,0 +1 @@ +# **[OpenCvSharp](https://github.com/shimat/opencvsharp) API Reference** diff --git a/docfx/toc.yml b/docfx/toc.yml new file mode 100644 index 000000000..d218707e7 --- /dev/null +++ b/docfx/toc.yml @@ -0,0 +1,3 @@ +- name: API Documentation + href: api/ + homepage: api/index.md diff --git a/docker/al2-dotnet5-opencv4.6.0/Dockerfile b/docker/al2-dotnet5-opencv4.6.0/Dockerfile new file mode 100644 index 000000000..ba2eddd39 --- /dev/null +++ b/docker/al2-dotnet5-opencv4.6.0/Dockerfile @@ -0,0 +1,90 @@ +FROM public.ecr.aws/lambda/dotnet:5.0 + +ENV OPENCV_VERSION=4.6.0 + +WORKDIR / + +RUN yum update -y && \ + yum groupinstall -y "Development Tools" && \ + yum install -y \ + wget openssl-devel cmake3 + +# Setup opencv and opencv-contrib source +RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake3 \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_barcode=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_js_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_objc_bindings_generator=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ + -D WITH_GSTREAMER=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j$(nproc) && make install + +# Download OpenCvSharp +RUN wget https://github.com/shimat/opencvsharp/archive/master.zip && \ + unzip master.zip && rm master.zip && \ + mv opencvsharp-master opencvsharp && \ + cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake3 -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib64/ +#RUN ldd /artifacts/libOpenCvSharpExtern.so + +# Test OpenCvSharpExtern +#RUN echo -e "\n\ +#int core_Mat_sizeof(); \n\ +#int main(){ \n\ +# int i = core_Mat_sizeof(); \n\ +# printf(\"sizeof(Mat) = %d\", i); \n\ +# return 0; \n\ +#}" > /test.c && \ +# gcc -I./ -L. test.c -o test -lOpenCvSharpExtern && \ +# ./test && \ +# rm -f /test* + +RUN rm -rf /opencvsharp diff --git a/docker/al2-opencv4.5.1/Dockerfile b/docker/al2-opencv4.5.1/Dockerfile new file mode 100644 index 000000000..c19270567 --- /dev/null +++ b/docker/al2-opencv4.5.1/Dockerfile @@ -0,0 +1,107 @@ +FROM amazonlinux:2.0.20200722.0 + +ENV OPENCV_VERSION=4.5.0 + +WORKDIR / + +RUN yum update -y && \ + yum groupinstall -y "Development Tools" && \ + yum install -y \ + wget openssl-devel cmake3 + +# Setup opencv and opencv-contrib source +RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake3 \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D WITH_GSTREAMER=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j8 && make install + +# Download OpenCvSharp +RUN wget https://github.com/shimat/opencvsharp/archive/master.zip && \ + unzip master.zip && rm master.zip && \ + mv opencvsharp-master opencvsharp && \ + cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake3 -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + mkdir /artifacts && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /artifacts/ && \ + cp /artifacts/libOpenCvSharpExtern.so /usr/lib64/ +#RUN ldd /artifacts/libOpenCvSharpExtern.so + +# Test OpenCvSharpExtern +RUN echo -e "\n\ +int core_Mat_sizeof(); \n\ +int main(){ \n\ + int i = core_Mat_sizeof(); \n\ + printf(\"sizeof(Mat) = %d\", i); \n\ + return 0; \n\ +}" > /test.c && \ + gcc -I./ -L. test.c -o test -lOpenCvSharpExtern && \ + ./test && \ + rm -f /test* + +RUN rm -rf /opencvsharp + +# Simple console app test using NuGet +RUN rpm -Uvh https://packages.microsoft.com/config/centos/8/packages-microsoft-prod.rpm && \ +yum install -y dotnet-sdk-3.1 +RUN dotnet --info +RUN dotnet new console -f netcoreapp3.1 -o "ConsoleApp01" && cd /ConsoleApp01 && \ + echo -e "\n\ +using System; \n\ +using OpenCvSharp; \n\ +class Program{ \n\ + static void Main(){ \n\ + Console.WriteLine(Cv2.GetTickCount()); \n\ + using var mat = new Mat(1, 1, MatType.CV_8UC1); \n\ + Console.WriteLine(mat.CvPtr); \n\ + } \n\ +}" > Program.cs && \ + dotnet add package OpenCvSharp4 && \ + dotnet run && \ + rm -rf /ConsoleApp01 diff --git a/docker/appengine-aspnetcore3.1-opencv4.5.1/Dockerfile b/docker/appengine-aspnetcore3.1-opencv4.5.1/Dockerfile new file mode 100644 index 000000000..ebc6a34b1 --- /dev/null +++ b/docker/appengine-aspnetcore3.1-opencv4.5.1/Dockerfile @@ -0,0 +1,135 @@ +FROM gcr.io/google-appengine/aspnetcore:3.1.9 + +ENV OPENCV_VERSION=4.5.1 + +WORKDIR / + +# Install opencv dependencies +RUN apt-get update && apt-get -y install --no-install-recommends \ + apt-transport-https \ + wget \ + unzip \ + curl \ + ca-certificates \ + build-essential \ + cmake \ + git \ + gfortran \ + libjpeg8-dev \ + libpng-dev \ + software-properties-common +RUN add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" && \ + apt-get update && apt-get -y install --no-install-recommends \ + libjasper1 \ + libtiff-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-22-dev \ + libxine2-dev \ + libv4l-dev +RUN cd /usr/include/linux && ln -s -f ../libv4l1-videodev.h videodev.h && cd ~ && \ + apt-get -y install --no-install-recommends \ + libgtk2.0-dev libtbb-dev qt5-default \ + libatlas-base-dev \ + libfaac-dev \ + libmp3lame-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + libavresample-dev \ + x264 \ + v4l-utils \ + libwebp-dev \ + tesseract-ocr libtesseract-dev libleptonica-dev + +# Setup opencv and opencv-contrib source +RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D WITH_GSTREAMER=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j6 && make install && ldconfig + +# Download OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib/ + +# Test OpenCvSharpExtern +RUN echo "\n\ +#include \n\ +int core_Mat_sizeof(); \n\ +int main(){ \n\ + int i = core_Mat_sizeof(); \n\ + printf(\"sizeof(Mat) = %d\", i); \n\ + return 0; \n\ +}" > /test.c && \ + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern && \ + LD_LIBRARY_PATH=. ./test && \ + rm -f /test* + +RUN rm -rf /opencvsharp + +# Simple console app test using NuGet +RUN dotnet new console -f netcoreapp3.1 -o "ConsoleApp01" && cd /ConsoleApp01 && \ + echo "\n\ +using System; \n\ +using OpenCvSharp; \n\ +class Program{ \n\ + static void Main(){ \n\ + Console.WriteLine(Cv2.GetTickCount()); \n\ + using var mat = new Mat(1, 1, MatType.CV_8UC1); \n\ + Console.WriteLine(mat.CvPtr); \n\ + } \n\ +}" > Program.cs && \ + dotnet add package OpenCvSharp4 && \ + dotnet run && \ + rm -rf /ConsoleApp01 diff --git a/docker/command_sample.txt b/docker/command_sample.txt new file mode 100644 index 000000000..a67064515 --- /dev/null +++ b/docker/command_sample.txt @@ -0,0 +1,4 @@ +docker build -t shimat/appengine-aspnetcore2.1-opencv4.2.0 . + +docker login +docker push shimat/appengine-aspnetcore2.1-opencv4.2.0 diff --git a/docker/ubuntu20-dotnet6-opencv4.6.0/Dockerfile b/docker/ubuntu20-dotnet6-opencv4.6.0/Dockerfile new file mode 100644 index 000000000..705a5f3ee --- /dev/null +++ b/docker/ubuntu20-dotnet6-opencv4.6.0/Dockerfile @@ -0,0 +1,160 @@ +FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal as builder + +ENV DEBIAN_FRONTEND=noninteractive +ENV OPENCV_VERSION=4.6.0 + +WORKDIR / + +# Install opencv dependencies +RUN apt-get update && apt-get -y install --no-install-recommends \ + apt-transport-https \ + software-properties-common \ + wget \ + unzip \ + ca-certificates \ + build-essential \ + cmake \ + git \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-22-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + libavresample-dev \ + x264 \ + libtesseract-dev \ + libgdiplus \ + && apt-get -y clean \ + && rm -rf /var/lib/apt/lists/* + +# Setup opencv and opencv-contrib source +RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_barcode=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_js_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_objc_bindings_generator=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ + -D WITH_GSTREAMER=OFF \ + -D WITH_ADE=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j$(nproc) && make install && ldconfig + +# Download OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j$(nproc) && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib/ + + +########## Test native .so file ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal +RUN apt-get update && apt-get -y install --no-install-recommends gcc +# /usr/lib/libOpenCvSharpExtern.so +# /usr/local/lib/libopencv_*.a +COPY --from=builder /usr/lib /usr/lib +#COPY --from=builder /usr/local/lib /usr/local/lib + +RUN echo "\n\ +#include \n\ +int core_Mat_sizeof(); \n\ +int main(){ \n\ + int i = core_Mat_sizeof(); \n\ + printf(\"sizeof(Mat) = %d\", i); \n\ + return 0; \n\ +}" > /test.c && \ + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern && \ + LD_LIBRARY_PATH=. ./test + + +########## Test .NET class libraries ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal +COPY --from=builder /usr/lib /usr/lib +# Install Build the C# part of OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp +RUN cd /opencvsharp/src/OpenCvSharp && \ + dotnet build -c Release -f net6.0 && \ + cd /opencvsharp/src/OpenCvSharp.Extensions && \ + dotnet build -c Release -f net6.0 + +RUN dotnet test /opencvsharp/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj -c Release -f net6.0 --runtime ubuntu.20.04-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null + +# Simple console app test using NuGet +# RUN dotnet new console -f net6.0 -o "ConsoleApp01" && cd /ConsoleApp01 && \ +# echo "\n\ +#using System; \n\ +#using OpenCvSharp; \n\ +#class Program{ \n\ +# static void Main(){ \n\ +# Console.WriteLine(Cv2.GetTickCount()); \n\ +# using var mat = new Mat(1, 1, MatType.CV_8UC1); \n\ +# Console.WriteLine(mat.CvPtr); \n\ +# } \n\ +#}" > Program.cs && \ +# dotnet add package OpenCvSharp4 && \ +# dotnet run && \ +# rm -rf /ConsoleApp01 + +#RUN ldd /artifacts/libOpenCvSharpExtern.so + + + +########## Final image ########## + +FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal as final +COPY --from=builder /usr/lib /usr/lib diff --git a/docker/ubuntu20-dotnet6-opencv4.7.0/Dockerfile b/docker/ubuntu20-dotnet6-opencv4.7.0/Dockerfile new file mode 100644 index 000000000..9acaef9e9 --- /dev/null +++ b/docker/ubuntu20-dotnet6-opencv4.7.0/Dockerfile @@ -0,0 +1,160 @@ +FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal as builder + +ENV DEBIAN_FRONTEND=noninteractive +ENV OPENCV_VERSION=4.7.0 + +WORKDIR / + +# Install opencv dependencies +RUN apt-get update && apt-get -y install --no-install-recommends \ + apt-transport-https \ + software-properties-common \ + wget \ + unzip \ + ca-certificates \ + build-essential \ + cmake \ + git \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-22-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + libavresample-dev \ + x264 \ + libtesseract-dev \ + libgdiplus \ + && apt-get -y clean \ + && rm -rf /var/lib/apt/lists/* + +# Setup opencv and opencv-contrib source +RUN wget -q https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget -q https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_barcode=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_js_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_objc_bindings_generator=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ + -D WITH_GSTREAMER=OFF \ + -D WITH_ADE=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j$(nproc) && make install && ldconfig + +# Download OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j$(nproc) && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib/ + + +########## Test native .so file ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal +RUN apt-get update && apt-get -y install --no-install-recommends gcc +# /usr/lib/libOpenCvSharpExtern.so +# /usr/local/lib/libopencv_*.a +COPY --from=builder /usr/lib /usr/lib +#COPY --from=builder /usr/local/lib /usr/local/lib + +RUN echo "\n\ +#include \n\ +int core_Mat_sizeof(); \n\ +int main(){ \n\ + int i = core_Mat_sizeof(); \n\ + printf(\"sizeof(Mat) = %d\", i); \n\ + return 0; \n\ +}" > /test.c && \ + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern && \ + LD_LIBRARY_PATH=. ./test + + +########## Test .NET class libraries ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal +COPY --from=builder /usr/lib /usr/lib +# Install Build the C# part of OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp +RUN cd /opencvsharp/src/OpenCvSharp && \ + dotnet build -c Release -f net6.0 && \ + cd /opencvsharp/src/OpenCvSharp.Extensions && \ + dotnet build -c Release -f net6.0 + +RUN dotnet test /opencvsharp/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj -c Release -f net6.0 --runtime ubuntu.20.04-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null + +# Simple console app test using NuGet +# RUN dotnet new console -f net6.0 -o "ConsoleApp01" && cd /ConsoleApp01 && \ +# echo "\n\ +#using System; \n\ +#using OpenCvSharp; \n\ +#class Program{ \n\ +# static void Main(){ \n\ +# Console.WriteLine(Cv2.GetTickCount()); \n\ +# using var mat = new Mat(1, 1, MatType.CV_8UC1); \n\ +# Console.WriteLine(mat.CvPtr); \n\ +# } \n\ +#}" > Program.cs && \ +# dotnet add package OpenCvSharp4 && \ +# dotnet run && \ +# rm -rf /ConsoleApp01 + +#RUN ldd /artifacts/libOpenCvSharpExtern.so + + + +########## Final image ########## + +FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal as final +COPY --from=builder /usr/lib /usr/lib diff --git a/docker/ubuntu20-dotnet6sdk-opencv4.6.0/Dockerfile b/docker/ubuntu20-dotnet6sdk-opencv4.6.0/Dockerfile new file mode 100644 index 000000000..e05302449 --- /dev/null +++ b/docker/ubuntu20-dotnet6sdk-opencv4.6.0/Dockerfile @@ -0,0 +1,160 @@ +FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal as builder + +ENV DEBIAN_FRONTEND=noninteractive +ENV OPENCV_VERSION=4.6.0 + +WORKDIR / + +# Install opencv dependencies +RUN apt-get update && apt-get -y install --no-install-recommends \ + apt-transport-https \ + software-properties-common \ + wget \ + unzip \ + ca-certificates \ + build-essential \ + cmake \ + git \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-22-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + libavresample-dev \ + x264 \ + libtesseract-dev \ + libgdiplus \ + && apt-get -y clean \ + && rm -rf /var/lib/apt/lists/* + +# Setup opencv and opencv-contrib source +RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_barcode=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_js_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_objc_bindings_generator=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ + -D WITH_GSTREAMER=OFF \ + -D WITH_ADE=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j$(nproc) && make install && ldconfig + +# Download OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j$(nproc) && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib/ + + +########## Test native .so file ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal +RUN apt-get update && apt-get -y install --no-install-recommends gcc +# /usr/lib/libOpenCvSharpExtern.so +# /usr/local/lib/libopencv_*.a +COPY --from=builder /usr/lib /usr/lib +#COPY --from=builder /usr/local/lib /usr/local/lib + +RUN echo "\n\ +#include \n\ +int core_Mat_sizeof(); \n\ +int main(){ \n\ + int i = core_Mat_sizeof(); \n\ + printf(\"sizeof(Mat) = %d\", i); \n\ + return 0; \n\ +}" > /test.c && \ + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern && \ + LD_LIBRARY_PATH=. ./test + + +########## Test .NET class libraries ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal +COPY --from=builder /usr/lib /usr/lib +# Install Build the C# part of OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp +RUN cd /opencvsharp/src/OpenCvSharp && \ + dotnet build -c Release -f net6.0 && \ + cd /opencvsharp/src/OpenCvSharp.Extensions && \ + dotnet build -c Release -f net6.0 + +RUN dotnet test /opencvsharp/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj -c Release -f net6.0 --runtime ubuntu.20.04-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null + +# Simple console app test using NuGet +# RUN dotnet new console -f net6.0 -o "ConsoleApp01" && cd /ConsoleApp01 && \ +# echo "\n\ +# using System; \n\ +# using OpenCvSharp; \n\ +# class Program{ \n\ +# static void Main(){ \n\ +# Console.WriteLine(Cv2.GetTickCount()); \n\ +# using var mat = new Mat(1, 1, MatType.CV_8UC1); \n\ +# Console.WriteLine(mat.CvPtr); \n\ +# } \n\ +# }" > Program.cs && \ +# dotnet add package OpenCvSharp4 && \ +# dotnet run && \ +# rm -rf /ConsoleApp01 + +#RUN ldd /artifacts/libOpenCvSharpExtern.so + + + +########## Final image ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-focal as final +COPY --from=builder /usr/lib /usr/lib diff --git a/docker/ubuntu22-dotnet6-opencv4.7.0/Dockerfile b/docker/ubuntu22-dotnet6-opencv4.7.0/Dockerfile new file mode 100644 index 000000000..4974f8c86 --- /dev/null +++ b/docker/ubuntu22-dotnet6-opencv4.7.0/Dockerfile @@ -0,0 +1,162 @@ +FROM mcr.microsoft.com/dotnet/aspnet:6.0-jammy as builder + +ENV DEBIAN_FRONTEND=noninteractive +ENV OPENCV_VERSION=4.7.0 + +WORKDIR / + +# Install opencv dependencies +RUN apt-get update && apt-get -y install --no-install-recommends \ + apt-transport-https \ + software-properties-common \ + wget \ + unzip \ + ca-certificates \ + build-essential \ + cmake \ + git \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + x264 \ + libtesseract-dev \ + libgdiplus \ + && apt-get -y clean \ + && rm -rf /var/lib/apt/lists/* + +# Setup opencv and opencv-contrib source +RUN wget -q https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget -q https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_barcode=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_js_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_objc_bindings_generator=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ + -D WITH_GSTREAMER=OFF \ + -D WITH_ADE=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j$(nproc) && make install && ldconfig + +# Download OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j$(nproc) && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib/ && \ + mkdir /artifacts && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /artifacts/ + + +########## Test native .so file ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy +RUN apt-get update && apt-get -y install --no-install-recommends gcc +# /usr/lib/libOpenCvSharpExtern.so +# /usr/local/lib/libopencv_*.a +COPY --from=builder /usr/lib /usr/lib +#COPY --from=builder /usr/local/lib /usr/local/lib + +RUN echo "\n\ +#include \n\ +int core_Mat_sizeof(); \n\ +int main(){ \n\ + int i = core_Mat_sizeof(); \n\ + printf(\"sizeof(Mat) = %d\", i); \n\ + return 0; \n\ +}" > /test.c && \ + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern && \ + LD_LIBRARY_PATH=. ./test + + +########## Test .NET class libraries ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy +COPY --from=builder /usr/lib /usr/lib +# Install Build the C# part of OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp +RUN cd /opencvsharp/src/OpenCvSharp && \ + dotnet build -c Release -f net6.0 && \ + cd /opencvsharp/src/OpenCvSharp.Extensions && \ + dotnet build -c Release -f net6.0 + +RUN dotnet test /opencvsharp/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj -c Release -f net6.0 --runtime ubuntu.20.04-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null + +# Simple console app test using NuGet +# RUN dotnet new console -f net6.0 -o "ConsoleApp01" && cd /ConsoleApp01 && \ +# echo "\n\ +#using System; \n\ +#using OpenCvSharp; \n\ +#class Program{ \n\ +# static void Main(){ \n\ +# Console.WriteLine(Cv2.GetTickCount()); \n\ +# using var mat = new Mat(1, 1, MatType.CV_8UC1); \n\ +# Console.WriteLine(mat.CvPtr); \n\ +# } \n\ +#}" > Program.cs && \ +# dotnet add package OpenCvSharp4 && \ +# dotnet run && \ +# rm -rf /ConsoleApp01 + +#RUN ldd /artifacts/libOpenCvSharpExtern.so + + + +########## Final image ########## + +FROM mcr.microsoft.com/dotnet/aspnet:6.0-jammy as final +COPY --from=builder /usr/lib /usr/lib +COPY --from=builder /artifacts /artifacts diff --git a/docker/ubuntu22-dotnet6-opencv4.8.0/Dockerfile b/docker/ubuntu22-dotnet6-opencv4.8.0/Dockerfile new file mode 100644 index 000000000..fe9d4235b --- /dev/null +++ b/docker/ubuntu22-dotnet6-opencv4.8.0/Dockerfile @@ -0,0 +1,162 @@ +FROM mcr.microsoft.com/dotnet/aspnet:6.0-jammy as builder + +ENV DEBIAN_FRONTEND=noninteractive +ENV OPENCV_VERSION=4.8.0 + +WORKDIR / + +# Install opencv dependencies +RUN apt-get update && apt-get -y install --no-install-recommends \ + apt-transport-https \ + software-properties-common \ + wget \ + unzip \ + ca-certificates \ + build-essential \ + cmake \ + git \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + x264 \ + libtesseract-dev \ + libgdiplus \ + && apt-get -y clean \ + && rm -rf /var/lib/apt/lists/* + +# Setup opencv and opencv-contrib source +RUN wget -q https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget -q https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_barcode=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_js_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_objc_bindings_generator=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ + -D WITH_GSTREAMER=OFF \ + -D WITH_ADE=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j$(nproc) && make install && ldconfig + +# Download OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j$(nproc) && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib/ && \ + mkdir /artifacts && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /artifacts/ + + +########## Test native .so file ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy +RUN apt-get update && apt-get -y install --no-install-recommends gcc +# /usr/lib/libOpenCvSharpExtern.so +# /usr/local/lib/libopencv_*.a +COPY --from=builder /usr/lib /usr/lib +#COPY --from=builder /usr/local/lib /usr/local/lib + +RUN echo "\n\ +#include \n\ +int core_Mat_sizeof(); \n\ +int main(){ \n\ + int i = core_Mat_sizeof(); \n\ + printf(\"sizeof(Mat) = %d\", i); \n\ + return 0; \n\ +}" > /test.c && \ + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern && \ + LD_LIBRARY_PATH=. ./test + + +########## Test .NET class libraries ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy +COPY --from=builder /usr/lib /usr/lib +# Install Build the C# part of OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp +RUN cd /opencvsharp/src/OpenCvSharp && \ + dotnet build -c Release -f net6.0 && \ + cd /opencvsharp/src/OpenCvSharp.Extensions && \ + dotnet build -c Release -f net6.0 + +RUN dotnet test /opencvsharp/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj -c Release -f net6.0 --runtime ubuntu.20.04-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null + +# Simple console app test using NuGet +# RUN dotnet new console -f net6.0 -o "ConsoleApp01" && cd /ConsoleApp01 && \ +# echo "\n\ +#using System; \n\ +#using OpenCvSharp; \n\ +#class Program{ \n\ +# static void Main(){ \n\ +# Console.WriteLine(Cv2.GetTickCount()); \n\ +# using var mat = new Mat(1, 1, MatType.CV_8UC1); \n\ +# Console.WriteLine(mat.CvPtr); \n\ +# } \n\ +#}" > Program.cs && \ +# dotnet add package OpenCvSharp4 && \ +# dotnet run && \ +# rm -rf /ConsoleApp01 + +#RUN ldd /artifacts/libOpenCvSharpExtern.so + + + +########## Final image ########## + +FROM mcr.microsoft.com/dotnet/aspnet:6.0-jammy as final +COPY --from=builder /usr/lib /usr/lib +COPY --from=builder /artifacts /artifacts diff --git a/docker/ubuntu22-dotnet6sdk-opencv4.7.0/Dockerfile b/docker/ubuntu22-dotnet6sdk-opencv4.7.0/Dockerfile new file mode 100644 index 000000000..ac6dac800 --- /dev/null +++ b/docker/ubuntu22-dotnet6sdk-opencv4.7.0/Dockerfile @@ -0,0 +1,159 @@ +FROM mcr.microsoft.com/dotnet/aspnet:6.0-jammy as builder + +ENV DEBIAN_FRONTEND=noninteractive +ENV OPENCV_VERSION=4.7.0 + +WORKDIR / + +# Install opencv dependencies +RUN apt-get update && apt-get -y install --no-install-recommends \ + apt-transport-https \ + software-properties-common \ + wget \ + unzip \ + ca-certificates \ + build-essential \ + cmake \ + git \ + libtbb-dev \ + libatlas-base-dev \ + libgtk2.0-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libdc1394-dev \ + libxine2-dev \ + libv4l-dev \ + libtheora-dev \ + libvorbis-dev \ + libxvidcore-dev \ + libopencore-amrnb-dev \ + libopencore-amrwb-dev \ + x264 \ + libtesseract-dev \ + libgdiplus \ + && apt-get -y clean \ + && rm -rf /var/lib/apt/lists/* + +# Setup opencv and opencv-contrib source +RUN wget -q https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv-${OPENCV_VERSION} opencv && \ + wget -q https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ + unzip -q ${OPENCV_VERSION}.zip && \ + rm ${OPENCV_VERSION}.zip && \ + mv opencv_contrib-${OPENCV_VERSION} opencv_contrib + +# Build OpenCV +RUN cd opencv && mkdir build && cd build && \ + cmake \ + -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=OFF \ + -D ENABLE_CXX11=ON \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_JAVA=OFF \ + -D BUILD_opencv_app=OFF \ + -D BUILD_opencv_barcode=OFF \ + -D BUILD_opencv_java_bindings_generator=OFF \ + -D BUILD_opencv_js_bindings_generator=OFF \ + -D BUILD_opencv_python_bindings_generator=OFF \ + -D BUILD_opencv_python_tests=OFF \ + -D BUILD_opencv_ts=OFF \ + -D BUILD_opencv_js=OFF \ + -D BUILD_opencv_bioinspired=OFF \ + -D BUILD_opencv_ccalib=OFF \ + -D BUILD_opencv_datasets=OFF \ + -D BUILD_opencv_dnn_objdetect=OFF \ + -D BUILD_opencv_dpm=OFF \ + -D BUILD_opencv_fuzzy=OFF \ + -D BUILD_opencv_gapi=OFF \ + -D BUILD_opencv_intensity_transform=OFF \ + -D BUILD_opencv_mcc=OFF \ + -D BUILD_opencv_objc_bindings_generator=OFF \ + -D BUILD_opencv_rapid=OFF \ + -D BUILD_opencv_reg=OFF \ + -D BUILD_opencv_stereo=OFF \ + -D BUILD_opencv_structured_light=OFF \ + -D BUILD_opencv_surface_matching=OFF \ + -D BUILD_opencv_videostab=OFF \ + -D BUILD_opencv_wechat_qrcode=ON \ + -D WITH_GSTREAMER=OFF \ + -D WITH_ADE=OFF \ + -D OPENCV_ENABLE_NONFREE=ON \ + .. && make -j$(nproc) && make install && ldconfig + +# Download OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp + +# Install the Extern lib. +RUN mkdir /opencvsharp/make && cd /opencvsharp/make && \ + cmake -D CMAKE_INSTALL_PREFIX=/opencvsharp/make /opencvsharp/src && \ + make -j$(nproc) && make install && \ + rm -rf /opencv && \ + rm -rf /opencv_contrib && \ + cp /opencvsharp/make/OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib/ + + +########## Test native .so file ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy +RUN apt-get update && apt-get -y install --no-install-recommends gcc +# /usr/lib/libOpenCvSharpExtern.so +# /usr/local/lib/libopencv_*.a +COPY --from=builder /usr/lib /usr/lib +#COPY --from=builder /usr/local/lib /usr/local/lib + +RUN echo "\n\ +#include \n\ +int core_Mat_sizeof(); \n\ +int main(){ \n\ + int i = core_Mat_sizeof(); \n\ + printf(\"sizeof(Mat) = %d\", i); \n\ + return 0; \n\ +}" > /test.c && \ + gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern && \ + LD_LIBRARY_PATH=. ./test + + +########## Test .NET class libraries ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy +COPY --from=builder /usr/lib /usr/lib +# Install Build the C# part of OpenCvSharp +RUN git clone https://github.com/shimat/opencvsharp.git && cd opencvsharp +RUN cd /opencvsharp/src/OpenCvSharp && \ + dotnet build -c Release -f net6.0 && \ + cd /opencvsharp/src/OpenCvSharp.Extensions && \ + dotnet build -c Release -f net6.0 + +RUN dotnet test /opencvsharp/test/OpenCvSharp.Tests/OpenCvSharp.Tests.csproj -c Release -f net6.0 --runtime ubuntu.20.04-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null + +# Simple console app test using NuGet +# RUN dotnet new console -f net6.0 -o "ConsoleApp01" && cd /ConsoleApp01 && \ +# echo "\n\ +# using System; \n\ +# using OpenCvSharp; \n\ +# class Program{ \n\ +# static void Main(){ \n\ +# Console.WriteLine(Cv2.GetTickCount()); \n\ +# using var mat = new Mat(1, 1, MatType.CV_8UC1); \n\ +# Console.WriteLine(mat.CvPtr); \n\ +# } \n\ +# }" > Program.cs && \ +# dotnet add package OpenCvSharp4 && \ +# dotnet run && \ +# rm -rf /ConsoleApp01 + +#RUN ldd /artifacts/libOpenCvSharpExtern.so + + + +########## Final image ########## + +FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy as final +COPY --from=builder /usr/lib /usr/lib diff --git a/download_opencv_windows.ps1 b/download_opencv_windows.ps1 new file mode 100644 index 000000000..1efcabe2e --- /dev/null +++ b/download_opencv_windows.ps1 @@ -0,0 +1,27 @@ +$tag = "4.11.0.20250505" +$uriArray = @( + "https://github.com/shimat/opencv_files/releases/download/${tag}/opencv_win_x64.zip" + "https://github.com/shimat/opencv_files/releases/download/${tag}/opencv_win_x86.zip" +) + +function Download($uri, $outFile) { + Write-Host "Downloading ${uri}" + if (!(Test-Path $outFile)) { + Invoke-WebRequest -Uri $uri -OutFile $outFile -ErrorAction Stop + } +} + +New-Item opencv_files -Type directory -Force -ErrorAction Stop | Out-Null +cd opencv_files + +[Net.ServicePointManager]::SecurityProtocol = @([Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12) + +foreach ($uri in $uriArray) { + $outFile = [System.IO.Path]::GetFileName($uri) + $outFileWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($uri) + Download $uri $outFile + Expand-Archive -Path $outFile -DestinationPath $outFileWithoutExtension -Force -ErrorAction Stop + Remove-Item -Path $outFile -ErrorAction Stop +} + +cd .. diff --git a/download_tesseract_windows.ps1 b/download_tesseract_windows.ps1 new file mode 100644 index 000000000..515a685a1 --- /dev/null +++ b/download_tesseract_windows.ps1 @@ -0,0 +1,26 @@ +$uriArray = @( + "https://github.com/shimat/tesseract_vcpkg/releases/download/2023.07.06/tesseract_vcpkg.0.0.8-beta.nupkg" +) + +function Download($uri, $outFile) { + Write-Host "Downloading ${uri}" + if (!(Test-Path $outFile)) { + Invoke-WebRequest -Uri $uri -OutFile $outFile -ErrorAction Stop + } +} + +mkdir tesseract_files -Force -ErrorAction Stop | Out-Null +cd tesseract_files + +[Net.ServicePointManager]::SecurityProtocol = @([Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12) + +foreach ($uri in $uriArray) { + $outFile = "tesseract_vcpkg.zip" + $outFileWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($outFile) + Download $uri $outFile + Expand-Archive -Path $outFile -DestinationPath $outFileWithoutExtension -Force -ErrorAction Stop + Move-Item $outFileWithoutExtension\*\* $outFileWithoutExtension + Remove-Item -Path $outFile -ErrorAction Stop +} + +cd .. diff --git a/nuget/OpenCvSharp4.Extensions.nuspec b/nuget/OpenCvSharp4.Extensions.nuspec new file mode 100644 index 000000000..773924eb8 --- /dev/null +++ b/nuget/OpenCvSharp4.Extensions.nuspec @@ -0,0 +1,59 @@ + + + + OpenCvSharp4.Extensions + 4.6.0.20220607 + OpenCvSharp GDI+ extension library. + shimat + Apache-2.0 + https://github.com/shimat/opencvsharp + https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png + false + OpenCvSharp GDI+ extension library. + OpenCvSharp GDI+ extension library. + + Copyright 2008-2020 + Image Processing OpenCV Wrapper FFI opencvsharp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/OpenCvSharp4.Windows.nuspec b/nuget/OpenCvSharp4.Windows.nuspec index 31ba39867..7218edb0c 100644 --- a/nuget/OpenCvSharp4.Windows.nuspec +++ b/nuget/OpenCvSharp4.Windows.nuspec @@ -2,10 +2,10 @@ OpenCvSharp4.Windows - 4.1.0.20190416 + 4.6.0.20220607 OpenCvSharp NuGet package for x64/x86 Windows (same as OpenCvSharp3-AnyCPU) shimat - BSD-3-Clause + Apache-2.0 https://github.com/shimat/opencvsharp https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png false @@ -14,22 +14,29 @@ Copyright 2008-2019 Image Processing OpenCV Wrapper FFI opencvsharp + - - - + + + + - - - + + + - - - + + + - - - + + + + + + + + diff --git a/nuget/OpenCvSharp4.WpfExtensions.nuspec b/nuget/OpenCvSharp4.WpfExtensions.nuspec new file mode 100644 index 000000000..f4c0d2deb --- /dev/null +++ b/nuget/OpenCvSharp4.WpfExtensions.nuspec @@ -0,0 +1,46 @@ + + + + OpenCvSharp4.WpfExtensions + 4.6.0.20220607 + OpenCvSharp WPF extension library. + shimat + Apache-2.0 + https://github.com/shimat/opencvsharp + https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png + false + OpenCvSharp WPF extension library. + OpenCvSharp WPF extension library. + + Copyright 2008-2020 + Image Processing OpenCV Wrapper FFI opencvsharp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/OpenCvSharp4.nuspec b/nuget/OpenCvSharp4.nuspec index 71558e928..36593351c 100644 --- a/nuget/OpenCvSharp4.nuspec +++ b/nuget/OpenCvSharp4.nuspec @@ -2,80 +2,56 @@ OpenCvSharp4 - 4.1.0.20190416 + 4.6.0.20220607 OpenCvSharp core library. A package of separate native bindings for your OS is required. shimat - BSD-3-Clause + Apache-2.0 https://github.com/shimat/opencvsharp https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png false OpenCV wrapper for .NET. Since this package includes only core managed libraries, another package of native bindings for your OS is required (OpenCvSharp4.runtime.*). OpenCV wrapper for .NET. Since this package includes only core managed libraries, another package of native bindings for your OS is required (OpenCvSharp4.runtime.*). - Copyright 2008-2019 + Copyright 2008-2020 Image Processing OpenCV Wrapper FFI opencvsharp + - - - + + + + - + + + + + + + + - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - + + + + + + + + - \ No newline at end of file + diff --git a/nuget/OpenCvSharp4.official.runtime.linux-x64.csproj b/nuget/OpenCvSharp4.official.runtime.linux-x64.csproj new file mode 100644 index 000000000..a3a5cda26 --- /dev/null +++ b/nuget/OpenCvSharp4.official.runtime.linux-x64.csproj @@ -0,0 +1,12 @@ + + + netstandard2.0;netstandard2.1;net6.0; + true + false + OpenCvSharp4.official.runtime.linux-x64.nuspec + + + + + diff --git a/nuget/OpenCvSharp4.runtime.ubuntu.18.04-x64.nuspec b/nuget/OpenCvSharp4.official.runtime.linux-x64.nuspec similarity index 54% rename from nuget/OpenCvSharp4.runtime.ubuntu.18.04-x64.nuspec rename to nuget/OpenCvSharp4.official.runtime.linux-x64.nuspec index aa8ba419d..0bbafe720 100644 --- a/nuget/OpenCvSharp4.runtime.ubuntu.18.04-x64.nuspec +++ b/nuget/OpenCvSharp4.official.runtime.linux-x64.nuspec @@ -1,27 +1,30 @@  - OpenCvSharp4.runtime.ubuntu.18.04-x64 - 4.1.0.20190416 - OpenCvSharp native bindings for ubuntu.18.04-x64 + OpenCvSharp4.official.runtime.linux-x64 + 4.6.0.20220608 + OpenCvSharp native bindings for Linux-x64 shimat - BSD-3-Clause + Apache-2.0 + https://github.com/shimat/opencvsharp https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png false - Internal implementation package for OpenCvSharp to work on Ubuntu 18.04 - Internal implementation package for OpenCvSharp to work on Ubuntu 18.04 + Internal implementation package for OpenCvSharp to work on Linux + Internal implementation package for OpenCvSharp to work on Linux Copyright 2008-2019 Image Processing OpenCV Wrapper FFI opencvsharp + - - + + + - + \ No newline at end of file diff --git a/nuget/OpenCvSharp4.runtime.linux-arm.csproj b/nuget/OpenCvSharp4.runtime.linux-arm.csproj new file mode 100644 index 000000000..6b5b9573d --- /dev/null +++ b/nuget/OpenCvSharp4.runtime.linux-arm.csproj @@ -0,0 +1,12 @@ + + + netstandard2.0;netstandard2.1;netcoreapp2.1; + true + false + OpenCvSharp4.runtime.linux-arm.nuspec + + + + + diff --git a/nuget/OpenCvSharp4.runtime.linux-arm.nuspec b/nuget/OpenCvSharp4.runtime.linux-arm.nuspec new file mode 100644 index 000000000..1f50b4061 --- /dev/null +++ b/nuget/OpenCvSharp4.runtime.linux-arm.nuspec @@ -0,0 +1,30 @@ + + + + OpenCvSharp4.runtime.linux-arm + 4.3.0.20191030 + OpenCvSharp native bindings for linux-arm + shimat + Apache-2.0 + + https://github.com/shimat/opencvsharp + https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png + false + Internal implementation package for OpenCvSharp to work on Ubuntu 18.04 for ARM + Internal implementation package for OpenCvSharp to work on Ubuntu 18.04 for ARM + + Copyright 2008-2019 + Image Processing OpenCV Wrapper FFI opencvsharp + + + + + + + + + + + + + diff --git a/nuget/OpenCvSharp4.runtime.osx.10.15-x64.csproj b/nuget/OpenCvSharp4.runtime.osx.10.15-x64.csproj new file mode 100644 index 000000000..322ffa6b1 --- /dev/null +++ b/nuget/OpenCvSharp4.runtime.osx.10.15-x64.csproj @@ -0,0 +1,12 @@ + + + netstandard2.0;netstandard2.1;netcoreapp2.1; + true + false + OpenCvSharp4.runtime.osx.10.15-x64.nuspec + + + + + diff --git a/nuget/OpenCvSharp4.runtime.osx.10.15-x64.nuspec b/nuget/OpenCvSharp4.runtime.osx.10.15-x64.nuspec new file mode 100644 index 000000000..5319b3cfb --- /dev/null +++ b/nuget/OpenCvSharp4.runtime.osx.10.15-x64.nuspec @@ -0,0 +1,30 @@ + + + + OpenCvSharp4.runtime.osx.10.15-x64 + 4.3.0.20191030 + OpenCvSharp native bindings for macOS.10.15-x64 + shimat,vladkol + Apache-2.0 + + https://github.com/shimat/opencvsharp + https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png + false + Internal implementation package for OpenCvSharp to work on macOS 10 + Internal implementation package for OpenCvSharp to work on macOS 10.15 + + Copyright 2008-2020 + Image Processing OpenCV Wrapper FFI opencvsharp + + + + + + + + + + + + + \ No newline at end of file diff --git a/nuget/OpenCvSharp4.runtime.uwp.nuspec b/nuget/OpenCvSharp4.runtime.uwp.nuspec new file mode 100644 index 000000000..88eafec93 --- /dev/null +++ b/nuget/OpenCvSharp4.runtime.uwp.nuspec @@ -0,0 +1,36 @@ + + + + OpenCvSharp4.runtime.uwp + 4.6.0.20220607 + OpenCvSharp4 native bindings for UWP x64/x86/ARM + shimat + Apache-2.0 + https://github.com/shimat/opencvsharp + https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png + false + Internal implementation package for OpenCvSharp to work on UWP (Universal Windows Platform). + Internal implementation package for OpenCvSharp to work on UWP (Universal Windows Platform). + + Copyright 2008-2019 + Image Processing OpenCV Wrapper FFI opencvsharp + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/OpenCvSharp4.runtime.wasm.csproj b/nuget/OpenCvSharp4.runtime.wasm.csproj new file mode 100644 index 000000000..9640c42b7 --- /dev/null +++ b/nuget/OpenCvSharp4.runtime.wasm.csproj @@ -0,0 +1,12 @@ + + + net6.0; + true + false + OpenCvSharp4.runtime.wasm.nuspec + + + + + diff --git a/nuget/OpenCvSharp4.runtime.wasm.nuspec b/nuget/OpenCvSharp4.runtime.wasm.nuspec new file mode 100644 index 000000000..fef9e1803 --- /dev/null +++ b/nuget/OpenCvSharp4.runtime.wasm.nuspec @@ -0,0 +1,28 @@ + + + + OpenCvSharp4.runtime.wasm + 4.3.0.20191030 + OpenCvSharp native bindings for Wasm + shimat,vladkol + Apache-2.0 + + https://github.com/shimat/opencvsharp + https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png + false + Internal implementation package for OpenCvSharp to work on Wasm + Internal implementation package for OpenCvSharp to work on Wasm + + Copyright 2008-2020 + Image Processing OpenCV Wrapper FFI opencvsharp + + + + + + + + + + + \ No newline at end of file diff --git a/nuget/OpenCvSharp4.runtime.wasm.props b/nuget/OpenCvSharp4.runtime.wasm.props new file mode 100644 index 000000000..71c05c474 --- /dev/null +++ b/nuget/OpenCvSharp4.runtime.wasm.props @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/nuget/OpenCvSharp4.runtime.win.nuspec b/nuget/OpenCvSharp4.runtime.win.nuspec index 7e9f5bac9..07ae74dfb 100644 --- a/nuget/OpenCvSharp4.runtime.win.nuspec +++ b/nuget/OpenCvSharp4.runtime.win.nuspec @@ -2,23 +2,24 @@ OpenCvSharp4.runtime.win - 4.1.0.20190416 - OpenCvSharp4 native bindings for Windows x64/x86 + 4.6.0.20220607 + OpenCvSharp4 native bindings for Windows x64/x86 (except UWP) shimat - BSD-3-Clause + Apache-2.0 https://github.com/shimat/opencvsharp https://raw.githubusercontent.com/shimat/opencvsharp/master/nuget/icon/opencvsharp.png false - Internal implementation package for OpenCvSharp to work on Windows. - Internal implementation package for OpenCvSharp to work on Windows. + Internal implementation package for OpenCvSharp to work on Windows except UWP. + Internal implementation package for OpenCvSharp to work on Windows except UWP. - Copyright 2008-2019 + Copyright 2008-2020 Image Processing OpenCV Wrapper FFI opencvsharp + - - - + + + @@ -26,8 +27,11 @@ - - - + + + + + + - \ No newline at end of file + diff --git a/nuget/OpenCvSharp4.runtime.win.props b/nuget/OpenCvSharp4.runtime.win.props index 785fbea16..af4e6a20e 100644 --- a/nuget/OpenCvSharp4.runtime.win.props +++ b/nuget/OpenCvSharp4.runtime.win.props @@ -1,25 +1,25 @@  - $(MSBuildThisFileDirectory)..\..\runtimes + $(MSBuildThisFileDirectory)..\..\runtimes - - + + dll\x86\OpenCvSharpExtern.dll PreserveNewest - - - dll\x86\opencv_ffmpeg410.dll + + + dll\x86\opencv_videoio_ffmpeg4110.dll PreserveNewest - + - - + + dll\x64\OpenCvSharpExtern.dll PreserveNewest - - - dll\x64\opencv_ffmpeg410_64.dll + + + dll\x64\opencv_videoio_ffmpeg4110_64.dll PreserveNewest - + diff --git a/nuget/nuget.exe b/nuget/nuget.exe deleted file mode 100644 index 041d81257..000000000 Binary files a/nuget/nuget.exe and /dev/null differ diff --git a/opencv_files_410 b/opencv_files_410 deleted file mode 160000 index 575b4c993..000000000 --- a/opencv_files_410 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 575b4c99390ebd79387c42443784cb52a3e586c3 diff --git a/samples b/samples index 9a95054d7..42322d297 160000 --- a/samples +++ b/samples @@ -1 +1 @@ -Subproject commit 9a95054d7f49de2fa49191862e44ad03dc3c1372 +Subproject commit 42322d297b313d9f115cba80773f2496a8c9cd9f diff --git a/src/OpenCvSharp.Blob/BlobRenderer.cs b/src/OpenCvSharp.Blob/BlobRenderer.cs deleted file mode 100644 index c76d1d1f1..000000000 --- a/src/OpenCvSharp.Blob/BlobRenderer.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -// Copyright (C) 2007 by Cristóbal Carnero Liñán -// grendel.ccl@gmail.com -// -// This file is part of cvBlob. -// -// cvBlob is free software: you can redistribute it and/or modify -// it under the terms of the Lesser GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cvBlob is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Lesser GNU General Public License for more details. -// -// You should have received a copy of the Lesser GNU General Public License -// along with cvBlob. If not, see . - -namespace OpenCvSharp.Blob -{ - /// - /// - /// - internal static class BlobRenderer - { - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static unsafe void PerformOne(LabelData labels, CvBlob blob, Mat imgSrc, Mat imgDst, - RenderBlobsMode mode, Scalar color, double alpha) - { - if (labels == null) - throw new ArgumentNullException(nameof(labels)); - if (blob == null) - throw new ArgumentNullException(nameof(blob)); - if (imgSrc == null) - throw new ArgumentNullException(nameof(imgSrc)); - if (imgDst == null) - throw new ArgumentNullException(nameof(imgDst)); - if (imgDst.Type() != MatType.CV_8UC3) - throw new ArgumentException("'img' must be a 3-channel U8 image."); - - if ((mode & RenderBlobsMode.Color) == RenderBlobsMode.Color) - { - var pSrc = imgSrc.GetGenericIndexer(); - var pDst = imgDst.GetGenericIndexer(); - - for (int r = blob.MinY; r <= blob.MaxY; r++) - { - for (int c = blob.MinX; c <= blob.MaxX; c++) - { - if (labels[r, c] == blob.Label) - { - byte v0 = (byte) ((1.0 - alpha)*pSrc[r, c].Item0 + alpha*color.Val0); - byte v1 = (byte) ((1.0 - alpha)*pSrc[r, c].Item1 + alpha*color.Val1); - byte v2 = (byte) ((1.0 - alpha)*pSrc[r, c].Item2 + alpha*color.Val2); - pDst[r, c] = new Vec3b(v0, v1, v2); - } - } - } - } - - if (mode != RenderBlobsMode.None) - { - if ((mode & RenderBlobsMode.BoundingBox) == RenderBlobsMode.BoundingBox) - { - Cv2.Rectangle( - imgDst, - new Point(blob.MinX, blob.MinY), - new Point(blob.MaxX, blob.MaxY), - new Scalar(255, 0, 0)); - } - if ((mode & RenderBlobsMode.Angle) == RenderBlobsMode.Angle) - { - double angle = blob.Angle(); - double lengthLine = Math.Max(blob.MaxX - blob.MinX, blob.MaxY - blob.MinY) / 2.0; - double x1 = blob.Centroid.X - lengthLine * Math.Cos(angle); - double y1 = blob.Centroid.Y - lengthLine * Math.Sin(angle); - double x2 = blob.Centroid.X + lengthLine * Math.Cos(angle); - double y2 = blob.Centroid.Y + lengthLine * Math.Sin(angle); - Cv2.Line(imgDst, new Point((int)x1, (int)y1), new Point((int)x2, (int)y2), - new Scalar(0, 255, 0)); - } - if ((mode & RenderBlobsMode.Centroid) == RenderBlobsMode.Centroid) - { - Cv2.Line(imgDst, - new Point((int)blob.Centroid.X - 3, (int)blob.Centroid.Y), - new Point((int)blob.Centroid.X + 3, (int)blob.Centroid.Y), - new Scalar(255, 0, 0)); - Cv2.Line(imgDst, - new Point((int)blob.Centroid.X, (int)blob.Centroid.Y - 3), - new Point((int)blob.Centroid.X, (int)blob.Centroid.Y + 3), - new Scalar(255, 0, 0)); - } - } - } - - /// - /// - /// - /// - /// - /// - /// - /// - public static void PerformMany(CvBlobs blobs, Mat imgSrc, Mat imgDst, RenderBlobsMode mode, double alpha) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - if (imgSrc == null) - throw new ArgumentNullException(nameof(imgSrc)); - if (imgDst == null) - throw new ArgumentNullException(nameof(imgDst)); - if (imgDst.Type() != MatType.CV_8UC3) - throw new ArgumentException("'img' must be a 3-channel U8 image."); - - var palette = new Dictionary(); - if ((mode & RenderBlobsMode.Color) == RenderBlobsMode.Color) - { - int colorCount = 0; - foreach (var kv in blobs) - { - double r, g, b; - Hsv2Rgb((colorCount*77) % 360, 0.5, 1.0, out r, out g, out b); - colorCount++; - palette[kv.Key] = new Scalar(b, g, r); - } - } - - foreach (var kv in blobs) - { - Scalar color = default (Scalar); - if (palette.ContainsKey(kv.Key)) - color = palette[kv.Key]; - PerformOne(blobs.Labels, kv.Value, imgSrc, imgDst, mode, color, alpha); - } - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - private static void Hsv2Rgb(double h, double s, double v, out double r, out double g, out double b) - { - double hh = h / 60.0; - int hf = (int)Math.Floor(hh); - int hi = ((int)hh) % 6; - double f = hh - hf; - - double p = v * (1.0 - s); - double q = v * (1.0 - f * s); - double t = v * (1.0 - (1.0 - f) * s); - - switch (hi) - { - case 0: - r = 255.0 * v; - g = 255.0 * t; - b = 255.0 * p; - break; - case 1: - r = 255.0 * q; - g = 255.0 * v; - b = 255.0 * p; - break; - case 2: - r = 255.0 * p; - g = 255.0 * v; - b = 255.0 * t; - break; - case 3: - r = 255.0 * p; - g = 255.0 * q; - b = 255.0 * v; - break; - case 4: - r = 255.0 * t; - g = 255.0 * p; - b = 255.0 * v; - break; - case 5: - r = 255.0 * v; - g = 255.0 * p; - b = 255.0 * q; - break; - default: - throw new Exception(); - } - } - } -} diff --git a/src/OpenCvSharp.Blob/CvBlob.cs b/src/OpenCvSharp.Blob/CvBlob.cs deleted file mode 100644 index ae0ba8672..000000000 --- a/src/OpenCvSharp.Blob/CvBlob.cs +++ /dev/null @@ -1,292 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace OpenCvSharp.Blob -{ - /// - /// Struct that contain information about one blob. - /// - [Serializable] - public class CvBlob - { - #region Init - - /// - /// Constructor - /// - public CvBlob() - { - Contour = new CvContourChainCode(); - InternalContours = new List(); - } - - /// - /// - /// - /// - /// - /// - internal CvBlob(int label, int x, int y) : this() - { - Label = label; - Area = 1; - MinX = x; - MaxX = x; - MinY = y; - MaxY = y; - M10 = x; - M01 = y; - M11 = x*y; - M20 = x*x; - M02 = y*y; - } - - #endregion - - #region Properties - - /// - /// Label assigned to the blob - /// - public int Label { get; set; } - - /// - /// Area (moment 00) - /// - public int Area { get; set; } - - /// - /// Area (moment 00) - /// - public int M00 - { - get { return Area; } - set { Area = value; } - } - - /// - /// X min - /// - public int MinX { get; set; } - - /// - /// X max - /// - public int MaxX { get; set; } - - /// - /// Y min - /// - public int MinY { get; set; } - - /// - /// Y max - /// - public int MaxY { get; set; } - - /// - /// CvRect(MinX, MinY, MaxX - MinX, MaxY - MinY) - /// - public Rect Rect - { - get { return new Rect(MinX, MinY, MaxX - MinX + 1, MaxY - MinY + 1); } - set - { - MinX = value.Left; - MinY = value.Top; - MaxX = value.Right; - MaxY = value.Bottom; - } - } - - /// - /// Centroid - /// - public Point2d Centroid { get; internal set; } - - /// - /// Moment 10 - /// - public double M10 { get; set; } - - /// - /// Moment 01 - /// - public double M01 { get; set; } - - /// - /// Moment 11 - /// - public double M11 { get; set; } - - /// - /// Moment 20 - /// - public double M20 { get; set; } - - /// - /// Moment 02 - /// - public double M02 { get; set; } - - /// - /// True if central moments are being calculated - /// - public bool CentralMoments { get; set; } - - /// - /// Central moment 11 - /// - public double U11 { get; internal set; } - - /// - /// Central moment 20 - /// - public double U20 { get; internal set; } - - /// - /// Central moment 02 - /// - public double U02 { get; internal set; } - - /// - /// Normalized central moment 11. - /// - public double N11 { get; internal set; } - - /// - /// Normalized central moment 20. - /// - public double N20 { get; internal set; } - - /// - /// Normalized central moment 02. - /// - public double N02 { get; internal set; } - - /// - /// Hu moment 1. - /// - public double P1 { get; set; } - - /// - /// Hu moment 2. - /// - public double P2 { get; set; } - - /// - /// Contour - /// - public CvContourChainCode Contour { get; internal set; } - - /// - /// Internal contours - /// - public List InternalContours { get; internal set; } - - #endregion - - #region Methods - - /// - /// Calculates angle orientation of a blob. - /// This function uses central moments so cvCentralMoments should have been called before for this blob. (cvAngle) - /// - /// Angle orientation in radians. - public double Angle() - { - return 0.5*Math.Atan2(2.0*U11, (U20 - U02)); - } - - - /// - /// Calculates centroid. - /// Centroid will be returned and stored in the blob structure. (cvCentroid) - /// - /// Centroid. - public Point2d CalcCentroid() - { - Centroid = new Point2d(M10 / Area, M01 / Area); - return Centroid; - } - - /// - /// Save the image of a blob to a file. - /// The function uses an image (that can be the original pre-processed image or a processed one, or even the result of cvRenderBlobs, for example) and a blob structure. - /// Then the function saves a copy of the part of the image where the blob is. - /// - /// Name of the file. - /// Image. - public void SaveImage(string fileName, Mat img) - { - if (String.IsNullOrEmpty(fileName)) - throw new ArgumentNullException(nameof(fileName)); - if (img == null) - throw new ArgumentNullException(nameof(img)); - - using (var subMat = img.SubMat(Rect)) - { - subMat.SaveImage(fileName); - } - } - - /// - /// Set central/hu moments and centroid value from moment values (M**) - /// - public void SetMoments() - { - // 重心 - Centroid = new Point2d(M10/Area, M01/Area); - // 各モーメント - U11 = M11 - (M10*M01)/M00; - U20 = M20 - (M10*M10)/M00; - U02 = M02 - (M01*M01)/M00; - - double m00Pow2 = M00*M00; - N11 = U11/m00Pow2; - N20 = U20/m00Pow2; - N02 = U02/m00Pow2; - - P1 = N20 + N02; - double nn = N20 - N02; - P2 = nn*nn + 4.0*(N11*N11); - } - - /// - /// - /// - /// - public CvBlob Clone() - { - return new CvBlob - { - Area = Area, - CentralMoments = CentralMoments, - Centroid = Centroid, - Contour = Contour.Clone(), - InternalContours = new List(InternalContours), - Label = Label, - M00 = M00, - M01 = M01, - M02 = M02, - M10 = M10, - M11 = M11, - M20 = M20, - MaxX = MaxX, - MaxY = MaxY, - MinX = MinX, - MinY = MinY, - N02 = N02, - N11 = N11, - N20 = N20, - P1 = P1, - P2 = P2, - U02 = U02, - U11 = U11, - U20 = U20, - }; - } - - #endregion - } -} diff --git a/src/OpenCvSharp.Blob/CvBlobConst.cs b/src/OpenCvSharp.Blob/CvBlobConst.cs deleted file mode 100644 index 02d6bbebb..000000000 --- a/src/OpenCvSharp.Blob/CvBlobConst.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; - -namespace OpenCvSharp.Blob -{ - /// - /// Constants which are defined by cvblob - /// - public static class CvBlobConst - { - // ReSharper disable InconsistentNaming - - #region RenderBlobsMode - - /// - /// Render each blog with a different color. - /// - - public const ushort CV_BLOB_RENDER_COLOR = 0x0001; - - /// - /// Render centroid. - /// - public const ushort CV_BLOB_RENDER_CENTROID = 0x0002; - - /// - /// Render bounding box. - /// - public const ushort CV_BLOB_RENDER_BOUNDING_BOX = 0x0004; - - /// - /// Render angle. - /// - public const ushort CV_BLOB_RENDER_ANGLE = 0x0008; - - /// - /// Print blob data to log out. - /// - public const ushort CV_BLOB_RENDER_TO_LOG = 0x0010; - - /// - /// Print blob data to std out. - /// - public const ushort CV_BLOB_RENDER_TO_STD = 0x0020; - - #endregion - - #region CvChainCode - - /// - /// Up. - /// - public const byte CV_CHAINCODE_UP = 0; - - /// - /// Up and right. - /// - public const byte CV_CHAINCODE_UP_RIGHT = 1; - - /// - /// Right. - /// - public const byte CV_CHAINCODE_RIGHT = 2; - - /// - /// Down and right. - /// - public const byte CV_CHAINCODE_DOWN_RIGHT = 3; - - /// - /// Down. - /// - public const byte CV_CHAINCODE_DOWN = 4; - - /// - /// Down and left. - /// - public const byte CV_CHAINCODE_DOWN_LEFT = 5; - - /// - /// Left. - /// - public const byte CV_CHAINCODE_LEFT = 6; - - /// - /// Up and left. - /// - public const byte CV_CHAINCODE_UP_LEFT = 7; - - /// - /// Move vectors of chain codes. - /// - public static readonly sbyte[][] ChainCodeMoves = new sbyte[][] - { - new sbyte[] {0, -1}, - new sbyte[] {1, -1}, - new sbyte[] {1, 0}, - new sbyte[] {1, 1}, - new sbyte[] {0, 1}, - new sbyte[] {-1, 1}, - new sbyte[] {-1, 0}, - new sbyte[] {-1, -1} - }; - - #endregion - - #region RenderTracksMode - - // ReSharper disable InconsistentNaming - /// - /// Print the ID of each track in the image. - /// - public const ushort CV_TRACK_RENDER_ID = 0x0001; - - /// - /// Draw bounding box of each track in the image. \see cvRenderTracks - /// - public const ushort CV_TRACK_RENDER_BOUNDING_BOX = 0x0002; - - /// - /// Print track info to log out. - /// - public const ushort CV_TRACK_RENDER_TO_LOG = 0x0010; - - /// - /// Print track info to log out. - /// - public const ushort CV_TRACK_RENDER_TO_STD = 0x0020; - - // ReSharper restore InconsistentNaming - - #endregion - } -} diff --git a/src/OpenCvSharp.Blob/CvBlobLib.cs b/src/OpenCvSharp.Blob/CvBlobLib.cs deleted file mode 100644 index d1b8505dc..000000000 --- a/src/OpenCvSharp.Blob/CvBlobLib.cs +++ /dev/null @@ -1,512 +0,0 @@ -using System; - -//#pragma warning disable 1591 - -namespace OpenCvSharp.Blob -{ - /// - /// Functions of cvblob library - /// - public static class CvBlobLib - { - /// - /// Calculates angle orientation of a blob. - /// This function uses central moments so cvCentralMoments should have been called before for this blob. (cvAngle) - /// - /// Blob. - /// Angle orientation in radians. - public static double CalcAngle(CvBlob blob) - { - if (blob == null) - throw new ArgumentNullException(nameof(blob)); - return blob.Angle(); - } - - /// - /// Calculates centroid. - /// Centroid will be returned and stored in the blob structure. (cvCentroid) - /// - /// Blob whose centroid will be calculated. - /// Centroid. - public static Point2d CalcCentroid(CvBlob blob) - { - if (blob == null) - throw new ArgumentNullException(nameof(blob)); - return blob.CalcCentroid(); - } - - /// - /// Calculates area of a polygonal contour. - /// - /// Contour (polygon type). - /// Area of the contour. - public static double ContourPolygonArea(CvContourPolygon polygon) - { - if (polygon == null) - throw new ArgumentNullException(nameof(polygon)); - return polygon.Area(); - } - - /// - /// Calculates the circularity of a polygon (compactness measure). - /// - /// Contour (polygon type). - /// Circularity: a non-negative value, where 0 correspond with a circumference. - public static double ContourPolygonCircularity(CvContourPolygon polygon) - { - if (polygon == null) - throw new ArgumentNullException(nameof(polygon)); - return polygon.Circularity(); - } - - /// - /// Calculates perimeter of a chain code contour. - /// - /// Contour (polygon type). - /// Perimeter of the contour. - public static double ContourPolygonPerimeter(CvContourPolygon polygon) - { - if (polygon == null) - throw new ArgumentNullException(nameof(polygon)); - return polygon.Perimeter(); - } - - /// - /// Calculates perimeter of a chain code contour. - /// - /// Contour (chain code type). - /// Perimeter of the contour. - public static double ContourChainCodePerimeter(CvContourChainCode cc) - { - if (cc == null) - throw new ArgumentNullException(nameof(cc)); - return cc.Perimeter(); - } - - /// - /// Convert a chain code contour to a polygon. - /// - /// Chain code contour. - /// A polygon. - public static CvContourPolygon ConvertChainCodesToPolygon(CvContourChainCode cc) - { - if (cc == null) - throw new ArgumentNullException(nameof(cc)); - return cc.ConvertToPolygon(); - } - - /// - /// Filter blobs by area. - /// Those blobs whose areas are not in range will be erased from the input list of blobs. (cvFilterByArea) - /// - /// List of blobs. - /// Minimun area. - /// Maximun area. - public static void FilterByArea(CvBlobs blobs, int minArea, int maxArea) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - blobs.FilterByArea(minArea, maxArea); - } - - /// - /// Filter blobs by label. - /// Delete all blobs except those with label l. - /// - /// List of blobs. - /// Label to leave. - public static void FilterByLabel(CvBlobs blobs, int label) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - blobs.FilterByLabel(label); - } - - /// - /// Draw a binary image with the blobs that have been given. (cvFilterLabels) - /// - /// List of blobs to be drawn. - /// Output binary image (depth=IPL_DEPTH_8U and nchannels=1). - public static void FilterLabels(CvBlobs blobs, Mat imgOut) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - blobs.FilterLabels(imgOut); - } - - /// - /// Get the label value from a labeled image. - /// - /// Blob data. - /// X coordenate. - /// Y coordenate. - /// Label value. - public static int GetLabel(CvBlobs blobs, int x, int y) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - return blobs.GetLabel(x, y); - } - - /// - /// Find greater blob. (cvGreaterBlob) - /// - /// List of blobs. - /// The greater blob. - public static CvBlob GreaterBlob(CvBlobs blobs) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - return blobs.GreaterBlob(); - } - - /// - /// Find the largest blob. (cvLargestBlob) - /// - /// List of blobs. - /// The largest blob. - public static CvBlob LargestBlob(CvBlobs blobs) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - return blobs.LargestBlob(); - } - - /// - /// Label the connected parts of a binary image. (cvLabel) - /// - /// Input binary image (depth=IPL_DEPTH_8U and num. channels=1). - /// List of blobs. - /// Number of pixels that has been labeled. - public static int Label(Mat img, CvBlobs blobs) - { - if (img == null) - throw new ArgumentNullException(nameof(img)); - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - - return blobs.Label(img); - } - - /// - /// Calculates mean color of a blob in an image. - /// - /// Blob list - /// The target blob - /// Original image. - /// Average color. - public static Scalar BlobMeanColor(CvBlobs blobs, CvBlob targetBlob, Mat originalImage) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - return blobs.BlobMeanColor(targetBlob, originalImage); - } - - /// - /// Calculates convex hull of a contour. - /// Uses the Melkman Algorithm. Code based on the version in http://w3.impa.br/~rdcastan/Cgeometry/. - /// - /// Contour (polygon type). - /// Convex hull. - public static CvContourPolygon PolygonContourConvexHull(CvContourPolygon polygon) - { - if (polygon == null) - throw new ArgumentNullException(nameof(polygon)); - return polygon.ContourConvexHull(); - } - - /// - /// Draws or prints information about a blob. - /// - /// Label data. - /// Blob. - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - public static void RenderBlob(LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest) - { - RenderBlob(labels, blob, imgSource, imgDest, (RenderBlobsMode) 0x000f, Scalar.White, 1.0); - } - - /// - /// Draws or prints information about a blob. - /// - /// Label data. - /// Blob. - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE. - public static void RenderBlob(LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest, - RenderBlobsMode mode) - { - RenderBlob(labels, blob, imgSource, imgDest, mode, Scalar.White, 1.0); - } - - /// - /// Draws or prints information about a blob. - /// - /// Label data. - /// Blob. - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE. - /// Color to render (if CV_BLOB_RENDER_COLOR is used). - /// If mode CV_BLOB_RENDER_COLOR is used. 1.0 indicates opaque and 0.0 translucent (1.0 by default). - public static void RenderBlob(LabelData labels, CvBlob blob, Mat imgSource, Mat imgDest, - RenderBlobsMode mode, Scalar color, double alpha = 1.0) - { - if (labels == null) - throw new ArgumentNullException(nameof(labels)); - if (blob == null) - throw new ArgumentNullException(nameof(blob)); - if (imgSource == null) - throw new ArgumentNullException(nameof(imgSource)); - if (imgDest == null) - throw new ArgumentNullException(nameof(imgDest)); - - BlobRenderer.PerformOne(labels, blob, imgSource, imgDest, mode, color, alpha); - } - - /// - /// Draws or prints information about blobs. (cvRenderBlobs) - /// - /// List of blobs. - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - public static void RenderBlobs(CvBlobs blobs, Mat imgSource, Mat imgDest) - { - RenderBlobs(blobs, imgSource, imgDest, (RenderBlobsMode) 0x000f, 1.0); - } - - /// - /// Draws or prints information about blobs. (cvRenderBlobs) - /// - /// List of blobs. - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE. - /// If mode CV_BLOB_RENDER_COLOR is used. 1.0 indicates opaque and 0.0 translucent (1.0 by default). - public static void RenderBlobs(CvBlobs blobs, Mat imgSource, Mat imgDest, RenderBlobsMode mode, - double alpha = 1.0) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - if (imgSource == null) - throw new ArgumentNullException(nameof(imgSource)); - if (imgDest == null) - throw new ArgumentNullException(nameof(imgDest)); - - BlobRenderer.PerformMany(blobs, imgSource, imgDest, mode, alpha); - } - - /// - /// Draw a contour. - /// - /// Chain code contour. - /// Image to draw on. - public static void RenderContourChainCode(CvContourChainCode contour, Mat img) - { - if (contour == null) - throw new ArgumentNullException(nameof(contour)); - contour.Render(img); - } - - /// - /// Draw a contour. - /// - /// Chain code contour. - /// Image to draw on. - /// Color to draw (default, white). - public static void RenderContourChainCode(CvContourChainCode contour, Mat img, Scalar color) - { - if (contour == null) - throw new ArgumentNullException(nameof(contour)); - contour.Render(img, color); - } - - /// - /// Draw a polygon. - /// - /// Polygon contour. - /// Image to draw on. - public static void RenderContourPolygon(CvContourPolygon contour, Mat img) - { - if (contour == null) - throw new ArgumentNullException(nameof(contour)); - contour.Render(img); - } - - /// - /// Draw a polygon. - /// - /// Polygon contour. - /// Image to draw on. - /// Color to draw (default, white). - public static void RenderContourPolygon(CvContourPolygon contour, Mat img, Scalar color) - { - if (contour == null) - throw new ArgumentNullException(nameof(contour)); - contour.Render(img, color); - } - - /// - /// Prints tracks information. - /// - /// List of tracks. - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - public static void RenderTracks(CvTracks tracks, Mat imgSource, Mat imgDest) - { - if (tracks == null) - throw new ArgumentNullException(nameof(tracks)); - tracks.Render(imgSource, imgDest); - } - - /// - /// Prints tracks information. - /// - /// List of tracks. - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_TRACK_RENDER_ID. - public static void RenderTracks(CvTracks tracks, Mat imgSource, Mat imgDest, RenderTracksMode mode) - { - if (tracks == null) - throw new ArgumentNullException(nameof(tracks)); - tracks.Render(imgSource, imgDest, mode); - } - - /// - /// Prints tracks information. - /// - /// List of tracks. - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_TRACK_RENDER_ID. - /// - /// - /// - /// - public static void RenderTracks(CvTracks tracks, Mat imgSource, Mat imgDest, RenderTracksMode mode, - Scalar textColor, HersheyFonts fontFace = HersheyFonts.HersheySimplex, double fontScale = 1d, int thickness = 1) - { - if (tracks == null) - throw new ArgumentNullException(nameof(tracks)); - tracks.Render(imgSource, imgDest, mode, textColor, fontFace, fontScale, thickness); - } - - /// - /// Save the image of a blob to a file. - /// The function uses an image (that can be the original pre-processed image or a processed one, or even the result of cvRenderBlobs, for example) and a blob structure. - /// Then the function saves a copy of the part of the image where the blob is. - /// - /// Name of the file. - /// Image. - /// Blob. - public static void SaveImageBlob(string fileName, Mat img, CvBlob blob) - { - if (String.IsNullOrEmpty(fileName)) - throw new ArgumentNullException(nameof(fileName)); - if (blob == null) - throw new ArgumentNullException(nameof(blob)); - blob.SaveImage(fileName, img); - } - - /// - /// Simplify a polygon reducing the number of vertex according the distance "delta". - /// Uses a version of the Ramer-Douglas-Peucker algorithm (http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm). - /// - /// Contour (polygon type). - /// A simplify version of the original polygon. - public static CvContourPolygon SimplifyPolygon(CvContourPolygon polygon) - { - return polygon.Simplify(); - } - - /// - /// Simplify a polygon reducing the number of vertex according the distance "delta". - /// Uses a version of the Ramer-Douglas-Peucker algorithm (http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm). - /// - /// Contour (polygon type). - /// Minimun distance. - /// A simplify version of the original polygon. - public static CvContourPolygon SimplifyPolygon(CvContourPolygon polygon, double delta) - { - if (polygon == null) - throw new ArgumentNullException(nameof(polygon)); - return polygon.Simplify(delta); - } - - /// - /// Updates list of tracks based on current blobs. - /// - /// List of blobs. - /// List of tracks. - /// Max distance to determine when a track and a blob match. - /// Max number of frames a track can be inactive. - public static void UpdateTracks(CvBlobs blobs, CvTracks tracks, double thDistance, int thInactive) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - blobs.UpdateTracks(tracks, thDistance, thInactive); - } - - /// - /// Updates list of tracks based on current blobs. - /// - /// List of blobs. - /// List of tracks. - /// Max distance to determine when a track and a blob match. - /// Max number of frames a track can be inactive. - /// If a track becomes inactive but it has been active less than thActive frames, the track will be deleted. - /// - /// Tracking based on: - /// A. Senior, A. Hampapur, Y-L Tian, L. Brown, S. Pankanti, R. Bolle. Appearance Models for - /// Occlusion Handling. Second International workshop on Performance Evaluation of Tracking and - /// Surveillance Systems & CVPR'01. December, 2001. - /// (http://www.research.ibm.com/peoplevision/PETS2001.pdf) - /// - public static void UpdateTracks(CvBlobs blobs, CvTracks tracks, double thDistance, int thInactive, int thActive) - { - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - blobs.UpdateTracks(tracks, thDistance, thInactive, thActive); - } - - /// - /// Write a contour to a CSV (Comma-separated values) file. - /// - /// Polygon contour. - /// File name. - public static void WriteContourPolygonCsv(CvContourPolygon polygon, string filename) - { - if (polygon == null) - throw new ArgumentNullException(nameof(polygon)); - polygon.WriteAsCsv(filename); - } - - /// - /// Write a contour to a SVG file. - /// - /// Polygon contour. - /// File name. - public static void WriteContourPolygonSvg(CvContourPolygon polygon, string fileName) - { - polygon.WriteAsSvg(fileName); - } - - /// - /// Write a contour to a SVG file. - /// - /// Polygon contour. - /// File name. - /// Stroke color (black by default). - /// Fill color (white by default). - public static void WriteContourPolygonSvg(CvContourPolygon polygon, string fileName, - Scalar stroke, Scalar fill) - { - if (polygon == null) - throw new ArgumentNullException(nameof(polygon)); - polygon.WriteAsSvg(fileName, stroke, fill); - } - } -} diff --git a/src/OpenCvSharp.Blob/CvBlobs.cs b/src/OpenCvSharp.Blob/CvBlobs.cs deleted file mode 100644 index 9affb752c..000000000 --- a/src/OpenCvSharp.Blob/CvBlobs.cs +++ /dev/null @@ -1,705 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -// Copyright (C) 2007 by Cristóbal Carnero Liñán -// grendel.ccl@gmail.com -// -// This file is part of cvBlob. -// -// cvBlob is free software: you can redistribute it and/or modify -// it under the terms of the Lesser GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cvBlob is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Lesser GNU General Public License for more details. -// -// You should have received a copy of the Lesser GNU General Public License -// along with cvBlob. If not, see . - -namespace OpenCvSharp.Blob -{ - /// - /// Blob set - /// - public class CvBlobs : Dictionary - { - /// - /// Label values - /// - public LabelData Labels { get; set; } - - /// - /// Constructor (init only) - /// - public CvBlobs() - { - } - - /// - /// Constructor (copy) - /// - public CvBlobs(IEnumerable> blobData, int[,] labelData) - { - foreach (KeyValuePair pair in blobData) - { - Add(pair.Key, pair.Value); - } - Labels = new LabelData(labelData); - } - - /// - /// Constructor (copy) - /// - public CvBlobs(IEnumerable> blobData, LabelData labelData) - : this(blobData, labelData.Values) - { - } - - /// - /// Constructor (init and cvLabel) - /// - /// Input binary image (depth=IPL_DEPTH_8U and nchannels=1). - public CvBlobs(Mat img) - { - if (img == null) - throw new ArgumentNullException(nameof(img)); - if (img.IsDisposed) - throw new ArgumentException("img is disposed"); - if (img.Type() != MatType.CV_8UC1) - throw new ArgumentException("img.Depth == BitDepth.U8 && img.NChannels == 1"); - - Label(img); - } - - #region Methods - - #region BlobMeanColor - - /// - /// Calculates mean color of a blob in an image. (cvBlobMeanColor) - /// - /// The target blob - /// Original image. - public Scalar BlobMeanColor(CvBlob targetBlob, Mat originalImage) - { - if (targetBlob == null) - throw new ArgumentNullException(nameof(targetBlob)); - if (originalImage == null) - throw new ArgumentNullException(nameof(originalImage)); - if (originalImage.Type() != MatType.CV_8UC3) - throw new ArgumentException("imgOut.Depth != BitDepth.U8 || imgOut.NChannels != 3"); - if (Labels == null) - throw new ArgumentException("blobs.Labels == null"); - - int width = originalImage.Cols; - int height = originalImage.Rows; - int mb = 0; - int mg = 0; - int mr = 0; - - var indexer = originalImage.GetGenericIndexer(); - for (int r = 0; r < height; r++) - { - for (int c = 0; c < width; c++) - { - if (Labels[r, c] == targetBlob.Label) - { - var v = indexer[r, c]; - mb += v.Item0; - mg += v.Item1; - mr += v.Item2; - } - } - } - - GC.KeepAlive(originalImage); - - int pixels = targetBlob.Area; - return new Scalar((byte) (mb/pixels), (byte) (mg/pixels), (byte) (mr/pixels)); - } - - #endregion - - #region FilterByArea - - /// - /// Filter blobs by area. - /// Those blobs whose areas are not in range will be erased from the input list of blobs. (cvFilterByArea) - /// - /// Minimun area. - /// Maximun area. - public void FilterByArea(int minArea, int maxArea) - { - int[] keys = new int[Count]; - Keys.CopyTo(keys, 0); - - foreach (int key in keys) - { - int area = this[key].Area; - if (area < minArea || area > maxArea) - { - Remove(key); - } - } - } - - #endregion - - #region FilterByLabel - - /// - /// Filter blobs by label. - /// Delete all blobs except those with label l. - /// - /// Label to leave. - public void FilterByLabel(int label) - { - int[] keys = new int[Count]; - Keys.CopyTo(keys, 0); - - foreach (int key in keys) - { - if (this[key].Label != label) - { - Remove(key); - } - } - } - - #endregion - - #region FilterLabels - - /// - /// Draw a binary image with the blobs that have been given. (cvFilterLabels) - /// - /// Output binary image (depth=IPL_DEPTH_8U and nchannels=1). - public void FilterLabels(Mat imgOut) - { - if (imgOut == null) - throw new ArgumentNullException(nameof(imgOut)); - if (imgOut.Type() != MatType.CV_8UC1) - throw new ArgumentException("imgOut.Depth != BitDepth.U8 || imgOut.NChannels != 1"); - if (Labels == null) - throw new ArgumentException("blobs.Labels == null"); - - Size size = Labels.Size; - int w = size.Width; - int h = size.Height; - var indexer = imgOut.GetGenericIndexer(); - - for (int r = 0; r < h; r++) - { - for (int c = 0; c < w; c++) - { - int label = Labels[r, c]; - if (label != 0) - { - if (ContainsKey(label)) - indexer[r, c] = 0xff; - else - indexer[r, c] = 0x00; - } - else - { - indexer[r, c] = 0x00; - } - } - } - } - - #endregion - - #region GreaterBlob - - /// - /// Find greater blob. (cvGreaterBlob) - /// - /// The greater blob. - public CvBlob GreaterBlob() - { - return LargestBlob(); - } - - /// - /// Find the largest blob. (cvGreaterBlob) - /// - /// The largest blob. - public CvBlob LargestBlob() - { - if (Count == 0) - return null; - - var list = new List>(this); - // 降順ソート - list.Sort((kv1, kv2) => - { - CvBlob b1 = kv1.Value; - CvBlob b2 = kv2.Value; - if (b1 == null) - return -1; - if (b2 == null) - return 1; - return b2.Area - b1.Area; - }); - return list[0].Value; - } - - #endregion - - #region GetLabel - - /// - /// Label the connected parts of a binary image. (cvLabel) - /// - /// - /// - /// Number of pixels that has been labeled. - public int GetLabel(int x, int y) - { - return Labels[y, x]; - } - - #endregion - - #region Label - - /// - /// Label the connected parts of a binary image. (cvLabel) - /// - /// Input binary image (depth=IPL_DEPTH_8U and num. channels=1). - /// Number of pixels that has been labeled. - public int Label(Mat img) - { - if (img == null) - throw new ArgumentNullException(nameof(img)); - - Labels = new LabelData(img.Height, img.Width); - return Labeller.Perform(img, this); - } - - #endregion - - #region RenderBlobs - - /// - /// Draws or prints information about blobs. (cvRenderBlobs) - /// - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - public void RenderBlobs(Mat imgSource, Mat imgDest) - { - CvBlobLib.RenderBlobs(this, imgSource, imgDest); - } - - /// - /// Draws or prints information about blobs. (cvRenderBlobs) - /// - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE. - public void RenderBlobs(Mat imgSource, Mat imgDest, RenderBlobsMode mode) - { - CvBlobLib.RenderBlobs(this, imgSource, imgDest, mode); - } - - /// - /// Draws or prints information about blobs. (cvRenderBlobs) - /// - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_BLOB_RENDER_COLOR|CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX|CV_BLOB_RENDER_ANGLE. - /// If mode CV_BLOB_RENDER_COLOR is used. 1.0 indicates opaque and 0.0 translucent (1.0 by default). - public void RenderBlobs(Mat imgSource, Mat imgDest, RenderBlobsMode mode, Double alpha) - { - CvBlobLib.RenderBlobs(this, imgSource, imgDest, mode, alpha); - } - - #endregion - - #region UpdateTracks - - /// - /// Updates list of tracks based on current blobs. - /// - /// List of tracks. - /// Max distance to determine when a track and a blob match. - /// Max number of frames a track can be inactive. - /// - /// Tracking based on: - /// A. Senior, A. Hampapur, Y-L Tian, L. Brown, S. Pankanti, R. Bolle. Appearance Models for - /// Occlusion Handling. Second International workshop on Performance Evaluation of Tracking and - /// Surveillance Systems & CVPR'01. December, 2001. - /// (http://www.research.ibm.com/peoplevision/PETS2001.pdf) - /// - public void UpdateTracks(CvTracks tracks, double thDistance, int thInactive) - { - UpdateTracks(tracks, thDistance, thInactive, 0); - } - - /// - /// Updates list of tracks based on current blobs. - /// - /// List of tracks. - /// Max distance to determine when a track and a blob match. - /// Max number of frames a track can be inactive. - /// If a track becomes inactive but it has been active less than thActive frames, the track will be deleted. - /// - /// Tracking based on: - /// A. Senior, A. Hampapur, Y-L Tian, L. Brown, S. Pankanti, R. Bolle. Appearance Models for - /// Occlusion Handling. Second International workshop on Performance Evaluation of Tracking and - /// Surveillance Systems & CVPR'01. December, 2001. - /// (http://www.research.ibm.com/peoplevision/PETS2001.pdf) - /// - public void UpdateTracks(CvTracks tracks, double thDistance, int thInactive, int thActive) - { - if (tracks == null) - throw new ArgumentNullException(nameof(tracks)); - - int nBlobs = this.Count; - int nTracks = tracks.Count; - - if (nBlobs == 0) - return; - - // Proximity matrix: - // Last row/column is for ID/label. - // Last-1 "/" is for accumulation. - var close = new ProximityMatrix(nBlobs, nTracks); - - // Initialization: - int i = 0; - foreach (CvBlob blob in Values) - { - close.AB[i] = 0; - close.IB[i] = blob.Label; - i++; - } - - int maxTrackId = 0; - int j = 0; - foreach (CvTrack track in tracks.Values) - { - close.AT[j] = 0; - close.IT[j] = track.Id; - if (track.Id > maxTrackId) - maxTrackId = track.Id; - j++; - } - - // Proximity matrix calculation and "used blob" list initialization: - for (i = 0; i < nBlobs; i++) - { - for (j = 0; j < nTracks; j++) - { - int ib = close.IB[i]; - int it = close.IT[j]; - CvBlob b = this[ib]; - CvTrack t = tracks[it]; - close[i, j] = (DistantBlobTrack(b, t) < thDistance) ? 1 : 0; - if (close[i, j] < thDistance) - { - close.AB[i]++; - close.AT[j]++; - } - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Detect inactive tracks - for (j = 0; j < nTracks; j++) - { - int c = close[nBlobs, j]; - if (c == 0) - { - //cout << "Inactive track: " << j << endl; - - // Inactive track. - CvTrack track = tracks[j]; - track.Inactive++; - track.Label = 0; - } - } - - // Detect new tracks - for (i = 0; i < nBlobs; i++) - { - int c = close.AB[i]; - if (c == 0) - { - //cout << "Blob (new track): " << maxTrackID+1 << endl; - //cout << *B(i) << endl; - - // New track. - maxTrackId++; - int ib = close.IB[i]; - CvBlob blob = this[ib]; - CvTrack track = new CvTrack - { - Id = maxTrackId, - Label = blob.Label, - MinX = blob.MinX, - MinY = blob.MinY, - MaxX = blob.MaxX, - MaxY = blob.MaxY, - Centroid = blob.Centroid, - LifeTime = 0, - Active = 0, - Inactive = 0, - }; - tracks[maxTrackId] = track; - //maxTrackId++; - } - } - - // Clustering - for (j = 0; j < nTracks; j++) - { - int c = close.AT[j]; - if (c != 0) - { - var tt = new List(); - var bb = new List(); - - int it = close.IT[j]; - tt.Add(tracks[it]); - - GetClusterForTrack(j, close, nBlobs, nTracks, this, tracks, bb, tt); - - // Select track - CvTrack track = null; - int area = 0; - foreach (CvTrack t in tt) - { - int a = (t.MaxX - t.MinX)*(t.MaxY - t.MinY); - if (a > area) - { - area = a; - track = t; - } - } - - // Select blob - CvBlob blob = null; - area = 0; - foreach (CvBlob b in Values) - { - if (b.Area > area) - { - area = b.Area; - blob = b; - } - } - - if (blob == null || track == null) - //throw new Exception(); - continue; - - // Update track - track.Label = blob.Label; - track.Centroid = blob.Centroid; - track.MinX = blob.MinX; - track.MinY = blob.MinY; - track.MaxX = blob.MaxX; - track.MaxY = blob.MaxY; - if (track.Inactive != 0) - track.Active = 0; - track.Inactive = 0; - - // Others to inactive - foreach (CvTrack t in tt) - { - if (t != track) - { - //cout << "Inactive: track=" << t->id << endl; - t.Inactive++; - t.Label = 0; - } - } - } - } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int[] trackKeys = new int[tracks.Count]; - tracks.Keys.CopyTo(trackKeys, 0); - foreach (int tkey in trackKeys) - { - CvTrack t = tracks[tkey]; - if ((t.Inactive >= thInactive) || - ((t.Inactive != 0) && (thActive != 0) && (t.Active < thActive))) - { - tracks.Remove(tkey); - } - else - { - t.LifeTime++; - if (t.Inactive == 0) - t.Active++; - } - } - } - - private double DistantBlobTrack(CvBlob b, CvTrack t) - { - double d1; - if (b.Centroid.X < t.MinX) - { - if (b.Centroid.Y < t.MinY) - d1 = Math.Max(t.MinX - b.Centroid.X, t.MinY - b.Centroid.Y); - else if (b.Centroid.Y > t.MaxY) - d1 = Math.Max(t.MinX - b.Centroid.X, b.Centroid.Y - t.MaxY); - else // if (t.MinY < b.Centroid.Y)&&(b.Centroid.Y < t.MaxY) - d1 = t.MinX - b.Centroid.X; - } - else if (b.Centroid.X > t.MaxX) - { - if (b.Centroid.Y < t.MinY) - d1 = Math.Max(b.Centroid.X - t.MaxX, t.MinY - b.Centroid.Y); - else if (b.Centroid.Y > t.MaxY) - d1 = Math.Max(b.Centroid.X - t.MaxX, b.Centroid.Y - t.MaxY); - else - d1 = b.Centroid.X - t.MaxX; - } - else // if (t.MinX =< b.Centroid.X) && (b.Centroid.X =< t.MaxX) - { - if (b.Centroid.Y < t.MinY) - d1 = t.MinY - b.Centroid.Y; - else if (b.Centroid.Y > t.MaxY) - d1 = b.Centroid.Y - t.MaxY; - else - return 0.0; - } - - double d2; - if (t.Centroid.X < b.MinX) - { - if (t.Centroid.Y < b.MinY) - d2 = Math.Max(b.MinX - t.Centroid.X, b.MinY - t.Centroid.Y); - else if (t.Centroid.Y > b.MaxY) - d2 = Math.Max(b.MinX - t.Centroid.X, t.Centroid.Y - b.MaxY); - else // if (b.MinY < t.Centroid.Y)&&(t.Centroid.Y < b.MaxY) - d2 = b.MinX - t.Centroid.X; - } - else if (t.Centroid.X > b.MaxX) - { - if (t.Centroid.Y < b.MinY) - d2 = Math.Max(t.Centroid.X - b.MaxX, b.MinY - t.Centroid.Y); - else if (t.Centroid.Y > b.MaxY) - d2 = Math.Max(t.Centroid.X - b.MaxX, t.Centroid.Y - b.MaxY); - else - d2 = t.Centroid.X - b.MaxX; - } - else // if (b.MinX =< t.Centroid.X) && (t.Centroid.X =< b.MaxX) - { - if (t.Centroid.Y < b.MinY) - d2 = b.MinY - t.Centroid.Y; - else if (t.Centroid.Y > b.MaxY) - d2 = t.Centroid.Y - b.MaxY; - else - return 0.0; - } - - return Math.Min(d1, d2); - } - - private static void GetClusterForBlob(int blobPos, ProximityMatrix close, - int nBlobs, int nTracks, CvBlobs blobs, CvTracks tracks, - List bb, List tt) - { - retry: - var retryList = new List(); - - for (int j = 0; j < nTracks; j++) - { - if (close[blobPos, j] != 0) - { - int it = close.IT[j]; - tt.Add(tracks[it]); - - int c = close.AT[j]; - - close[blobPos, j] = 0; - close.AB[blobPos]--; - close.AT[j]--; - - if (c > 1) - { - retryList.Add(j); - //GetClusterForTrack(j, close, nBlobs, nTracks, blobs, tracks, bb, tt); - } - } - } - - if (retryList.Count > 0) - { - foreach (int j in retryList) - { - GetClusterForTrack(j, close, nBlobs, nTracks, blobs, tracks, bb, tt); - } - goto retry; - } - } - - private static void GetClusterForTrack(int trackPos, ProximityMatrix close, - int nBlobs, int nTracks, CvBlobs blobs, - CvTracks tracks, List bb, List tt) - { - retry: - var retryList = new List(); - - for (int i = 0; i < nBlobs; i++) - { - if (close[i, trackPos] != 0) - { - int ib = close.IB[i]; - bb.Add(blobs[ib]); - - int c = close.AB[i]; - - close[i, trackPos] = 0; - close.AB[i]--; - close.AT[trackPos]--; - - if (c > 1) - { - retryList.Add(i); - //GetClusterForBlob(i, close, nBlobs, nTracks, blobs, tracks, bb, tt); - } - } - } - - if (retryList.Count > 0) - { - foreach (int i in retryList) - { - GetClusterForBlob(i, close, nBlobs, nTracks, blobs, tracks, bb, tt); - } - goto retry; - } - } - - #endregion - - /// - /// - /// - /// - public CvBlobs Clone() - { - var newBlobs = new CvBlobs(); - foreach (KeyValuePair pair in this) - { - newBlobs.Add(pair.Key, pair.Value); - } - newBlobs.Labels = Labels.Clone(); - - return newBlobs; - } - - #endregion - } -} diff --git a/src/OpenCvSharp.Blob/CvChainCode.cs b/src/OpenCvSharp.Blob/CvChainCode.cs deleted file mode 100644 index f020817b7..000000000 --- a/src/OpenCvSharp.Blob/CvChainCode.cs +++ /dev/null @@ -1,44 +0,0 @@ - -#pragma warning disable 1591 - -namespace OpenCvSharp.Blob -{ - /// - /// Chain code (direction) - /// - public enum CvChainCode : byte - { - /// - /// Up. - /// - Up = CvBlobConst.CV_CHAINCODE_UP, - /// - /// Up and right. - /// - UpRight = CvBlobConst.CV_CHAINCODE_UP_RIGHT, - /// - /// Right. - /// - Right = CvBlobConst.CV_CHAINCODE_RIGHT, - /// - /// Down and right. - /// - DownRight = CvBlobConst.CV_CHAINCODE_DOWN_RIGHT, - /// - /// Down. - /// - Down = CvBlobConst.CV_CHAINCODE_DOWN, - /// - /// Down and left. - /// - DownLeft = CvBlobConst.CV_CHAINCODE_DOWN_LEFT, - /// - /// Left. - /// - Left = CvBlobConst.CV_CHAINCODE_LEFT, - /// - /// Up and left. - /// - UpLeft = CvBlobConst.CV_CHAINCODE_UP_LEFT, - } -} \ No newline at end of file diff --git a/src/OpenCvSharp.Blob/CvContourChainCode.cs b/src/OpenCvSharp.Blob/CvContourChainCode.cs deleted file mode 100644 index eaf294d79..000000000 --- a/src/OpenCvSharp.Blob/CvContourChainCode.cs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2007 by Cristóbal Carnero Liñán -// grendel.ccl@gmail.com -// -// This file is part of cvBlob. -// -// cvBlob is free software: you can redistribute it and/or modify -// it under the terms of the Lesser GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cvBlob is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Lesser GNU General Public License for more details. -// -// You should have received a copy of the Lesser GNU General Public License -// along with cvBlob. If not, see . - -using System; -using System.Collections.Generic; - -namespace OpenCvSharp.Blob -{ - /// - /// - /// - public class CvContourChainCode - { - /// - /// Point where contour begin. - /// - public Point StartingPoint { get; set; } - - /// - /// Polygon description based on chain codes. - /// - public List ChainCode { get; set; } - - /// - /// - /// - public CvContourChainCode() - { - StartingPoint = default(Point); - ChainCode = new List(); - } - - /// - /// Convert a chain code contour to a polygon. - /// - /// A polygon. - public CvContourPolygon ConvertToPolygon() - { - CvContourPolygon contour = new CvContourPolygon(); - - int x = StartingPoint.X; - int y = StartingPoint.Y; - contour.Add(new Point(x, y)); - - if (ChainCode.Count > 0) - { - CvChainCode lastCode = ChainCode[0]; - x += CvBlobConst.ChainCodeMoves[(int) ChainCode[0]][0]; - y += CvBlobConst.ChainCodeMoves[(int) ChainCode[0]][1]; - for (int i = 1; i < ChainCode.Count; i++) - { - if (lastCode != ChainCode[i]) - { - contour.Add(new Point(x, y)); - lastCode = ChainCode[i]; - } - x += CvBlobConst.ChainCodeMoves[(int) ChainCode[i]][0]; - y += CvBlobConst.ChainCodeMoves[(int) ChainCode[i]][1]; - } - } - - return contour; - } - - /// - /// Calculates perimeter of a polygonal contour. - /// - /// Perimeter of the contour. - public double Perimeter() - { - double perimeter = 0.0; - foreach (CvChainCode cc in ChainCode) - { - int type = (int) cc; - if (type%2 != 0) - perimeter += Math.Sqrt(1.0 + 1.0); - else - perimeter += 1.0; - } - return perimeter; - } - - /// - /// Draw a contour. - /// - /// Image to draw on. - public void Render(Mat img) - { - Render(img, new Scalar(255, 255, 255)); - } - - /// - /// Draw a contour. - /// - /// Image to draw on. - /// Color to draw (default, white). - public void Render(Mat img, Scalar color) - { - if (img == null) - throw new ArgumentNullException(nameof(img)); - if (img.Type() != MatType.CV_8UC3) - throw new ArgumentException("Invalid img format (U8 3-channels)"); - - var indexer = img.GetGenericIndexer(); - int x = StartingPoint.X; - int y = StartingPoint.Y; - foreach (CvChainCode cc in ChainCode) - { - indexer[y, x] = new Vec3b((byte) color.Val0, (byte) color.Val1, (byte) color.Val2); - x += CvBlobConst.ChainCodeMoves[(int) cc][0]; - y += CvBlobConst.ChainCodeMoves[(int) cc][1]; - } - } - - /// - /// - /// - /// - public CvContourChainCode Clone() - { - return new CvContourChainCode - { - ChainCode = new List(ChainCode), - StartingPoint = StartingPoint, - }; - } - } -} diff --git a/src/OpenCvSharp.Blob/CvContourPolygon.cs b/src/OpenCvSharp.Blob/CvContourPolygon.cs deleted file mode 100644 index e8f8067d5..000000000 --- a/src/OpenCvSharp.Blob/CvContourPolygon.cs +++ /dev/null @@ -1,438 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -// Copyright (C) 2007 by Cristóbal Carnero Liñán -// grendel.ccl@gmail.com -// -// This file is part of cvBlob. -// -// cvBlob is free software: you can redistribute it and/or modify -// it under the terms of the Lesser GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cvBlob is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Lesser GNU General Public License for more details. -// -// You should have received a copy of the Lesser GNU General Public License -// along with cvBlob. If not, see . - -namespace OpenCvSharp.Blob -{ - /// - /// Polygon based contour. - /// - public class CvContourPolygon : List - { - /// - /// - /// - public CvContourPolygon() - { - } - - /// - /// - /// - /// - public CvContourPolygon(IEnumerable list) - : base(list) - { - } - - /// - /// Converts this to CSV string - /// - /// - public override string ToString() - { - StringBuilder sb = new StringBuilder(); - foreach (Point p in this) - { - sb.AppendFormat("{0},{1}", p.X, p.Y).AppendLine(); - } - return sb.ToString(); - } - - #region Area - - /// - /// Calculates area of a polygonal contour. - /// - /// Area of the contour. - public double Area() - { - if (Count <= 2) - return 1.0; - - Point lastPoint = this[Count - 1]; - double area = 0.0; - foreach (Point point in this) - { - area += lastPoint.X*point.Y - lastPoint.Y*point.X; - lastPoint = point; - } - return area*0.5; - } - - #endregion - - #region Circularity - - /// - /// Calculates the circularity of a polygon (compactness measure). - /// - /// Circularity: a non-negative value, where 0 correspond with a circumference. - public double Circularity() - { - double l = Perimeter(); - double c = (l*l/Area()) - 4.0*Math.PI; - - if (c >= 0.0) - return c; - // This could happen if the blob it's only a pixel: the perimeter will be 0. Another solution would be to force "cvContourPolygonPerimeter" to be 1 or greater. - return 0.0; - } - - #endregion - - #region ContourConvexHull - - /// - /// Calculates convex hull of a contour. - /// Uses the Melkman Algorithm. Code based on the version in http://w3.impa.br/~rdcastan/Cgeometry/. - /// - /// Convex hull. - public CvContourPolygon ContourConvexHull() - { - if (Count <= 3) - return new CvContourPolygon(this); - - var dq = new List(); // instead of std::deq... - - if (CrossProductPoints(this[0], this[1], this[2]) > 0) - { - dq.Add(this[0]); - dq.Add(this[1]); - } - else - { - dq.Add(this[1]); - dq.Add(this[0]); - } - - dq.Add(this[2]); - dq.Insert(0, this[2]); - - for (int i = 3; i < Count; i++) - { - int s = dq.Count; - - if ((CrossProductPoints(this[i], dq[0], dq[1]) >= 0) && - (CrossProductPoints(dq[s - 2], dq[s - 1], this[i]) >= 0)) - continue; // TODO Optimize. - - while (CrossProductPoints(dq[s - 2], dq[s - 1], this[i]) < 0) - { - dq.RemoveAt(dq.Count - 1); - s = dq.Count; - } - - dq.Add(this[i]); - - while (CrossProductPoints(this[i], dq[0], dq[1]) < 0) - dq.RemoveAt(0); - - dq.Insert(0, this[i]); - } - - return new CvContourPolygon(dq); - } - - private static double CrossProductPoints(Point a, Point b, Point c) - { - double abx = b.X - a.X; - double aby = b.Y - a.Y; - double acx = c.X - a.X; - double acy = c.Y - a.Y; - return abx*acy - aby*acx; - } - - #endregion - - #region ContourPolygonPerimeter - - /// - /// Calculates perimeter of a chain code contour. - /// - /// Perimeter of the contour. - public double Perimeter() - { - double perimeter = DistancePointPoint(this[Count - 1], this[0]); - for (int i = 0; i < Count - 1; i++) - { - perimeter += DistancePointPoint(this[i], this[i + 1]); - } - return perimeter; - } - - private static double DistancePointPoint(Point a, Point b) - { - double abx = a.X - b.X; - double aby = a.Y - b.Y; - return Math.Sqrt(abx*abx + aby*aby); - } - - #endregion - - #region Render - - /// - /// Draw a polygon. - /// - /// Image to draw on. - public void Render(Mat img) - { - Render(img, new Scalar(255, 255, 255)); - } - - /// - /// Draw a polygon. - /// - /// Image to draw on. - /// Color to draw (default, white). - public void Render(Mat img, Scalar color) - { - if (img == null) - throw new ArgumentNullException(nameof(img)); - if (img.Type() != MatType.CV_8UC3) - throw new ArgumentException("Invalid img format (U8 3-channels)"); - - if (Count == 0) - return; - - int fx = this[Count - 1].X; - int fy = this[Count - 1].Y; - foreach (Point p in this) - { - Cv2.Line(img, fx, fy, p.X, p.Y, color); - fx = p.X; - fy = p.Y; - } - } - - #endregion - - #region SimplifyPolygon - - /// - /// Simplify a polygon reducing the number of vertex according the distance "delta". - /// Uses a version of the Ramer-Douglas-Peucker algorithm (http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm). - /// - /// A simplify version of the original polygon. - public CvContourPolygon Simplify() - { - return Simplify(1.0); - } - - /// - /// Simplify a polygon reducing the number of vertex according the distance "delta". - /// Uses a version of the Ramer-Douglas-Peucker algorithm (http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm). - /// - /// Minimun distance. - /// A simplify version of the original polygon. - public CvContourPolygon Simplify(double delta) - { - double furtherDistance = 0.0; - int furtherIndex = 0; - - if (Count == 0) - return new CvContourPolygon(); - - for (int i = 1; i < Count; i++) - { - double d = DistancePointPoint(this[i], this[0]); - if (d > furtherDistance) - { - furtherDistance = d; - furtherIndex = i; - } - } - - if (furtherDistance < delta) - { - CvContourPolygon result = new CvContourPolygon(); - result.Add(this[0]); - return result; - } - else - { - bool[] pnUseFlag = new bool[Count]; - for (int i = 1; i < Count; i++) - pnUseFlag[i] = false; - - pnUseFlag[0] = pnUseFlag[furtherIndex] = true; - - SimplifyPolygonRecursive(this, 0, furtherIndex, pnUseFlag, delta); - SimplifyPolygonRecursive(this, furtherIndex, -1, pnUseFlag, delta); - - CvContourPolygon result = new CvContourPolygon(); - - for (int i = 0; i < Count; i++) - { - if (pnUseFlag[i]) - result.Add(this[i]); - } - return result; - } - } - - private static void SimplifyPolygonRecursive(CvContourPolygon p, int i1, int i2, bool[] pnUseFlag, double delta) - { - int endIndex = (i2 < 0) ? p.Count : i2; - - if (Math.Abs(i1 - endIndex) <= 1) - return; - - Point firstPoint = p[i1]; - Point lastPoint = (i2 < 0) ? p[0] : p[i2]; - - double furtherDistance = 0.0; - int furtherIndex = 0; - - for (int i = i1 + 1; i < endIndex; i++) - { - double d = DistanceLinePoint(firstPoint, lastPoint, p[i]); - - if ((d >= delta) && (d > furtherDistance)) - { - furtherDistance = d; - furtherIndex = i; - } - } - - if (furtherIndex > 0) - { - pnUseFlag[furtherIndex] = true; - - SimplifyPolygonRecursive(p, i1, furtherIndex, pnUseFlag, delta); - SimplifyPolygonRecursive(p, furtherIndex, i2, pnUseFlag, delta); - } - } - - private static double DistanceLinePoint(Point a, Point b, Point c, bool isSegment = true) - { - if (isSegment) - { - double dot1 = DotProductPoints(a, b, c); - if (dot1 > 0) return DistancePointPoint(b, c); - - double dot2 = DotProductPoints(b, a, c); - if (dot2 > 0) return DistancePointPoint(a, c); - } - return Math.Abs(CrossProductPoints(a, b, c)/DistancePointPoint(a, b)); - } - - private static double DotProductPoints(Point a, Point b, Point c) - { - double abx = b.X - a.X; - double aby = b.Y - a.Y; - double bcx = c.X - b.X; - double bcy = c.Y - b.Y; - return abx*bcx + aby*bcy; - } - - #endregion - - #region WriteAsCsv - - /// - /// Write a contour to a CSV (Comma-separated values) file. - /// - /// File name. - public void WriteAsCsv(string fileName) - { - using (var stream = new FileStream(fileName, FileMode.Create)) - using (var writer = new StreamWriter(stream)) - { - writer.Write(ToString()); - } - } - -#endregion - -#region WriteAsSvg - - /// - /// Write a contour to a SVG file. - /// - /// File name - public void WriteAsSvg(string fileName) - { - WriteAsSvg(fileName, Scalar.Black, Scalar.White); - } - - /// - /// Write a contour to a SVG file. - /// - /// File name - /// Stroke color - /// Fill color - public void WriteAsSvg(string fileName, Scalar stroke, Scalar fill) - { - using (var stream = new FileStream(fileName, FileMode.Create)) - using (var writer = new StreamWriter(stream)) - { - writer.WriteLine(ToSvg(stroke, fill)); - } - } - - /// - /// - /// - /// - /// - /// - public string ToSvg(Scalar stroke, Scalar fill) - { - int minx = Int32.MaxValue; - int miny = Int32.MaxValue; - int maxx = Int32.MinValue; - int maxy = Int32.MinValue; - - var buffer = new StringBuilder(); - foreach (Point p in this) - { - if (p.X > maxx) - maxx = p.X; - if (p.X < minx) - minx = p.X; - if (p.Y > maxy) - maxy = p.Y; - if (p.Y < miny) - miny = p.Y; - buffer.AppendFormat("{0},{1} ", p.X, p.Y); - } - - var builder = new StringBuilder() - .AppendLine("") - .AppendLine( - "") - .AppendFormat( - "", - maxx - minx, maxy - miny, minx, miny, maxx, maxy).AppendLine() - .AppendFormat( - "", - fill.Val0, fill.Val1, fill.Val2, stroke.Val0, stroke.Val1, stroke.Val2, buffer).AppendLine() - .AppendLine(""); - return builder.ToString(); - } - -#endregion - } -} diff --git a/src/OpenCvSharp.Blob/CvTrack.cs b/src/OpenCvSharp.Blob/CvTrack.cs deleted file mode 100644 index 04fd0b242..000000000 --- a/src/OpenCvSharp.Blob/CvTrack.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -// Copyright (C) 2007 by Cristóbal Carnero Liñán -// grendel.ccl@gmail.com -// -// This file is part of cvBlob. -// -// cvBlob is free software: you can redistribute it and/or modify -// it under the terms of the Lesser GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cvBlob is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Lesser GNU General Public License for more details. -// -// You should have received a copy of the Lesser GNU General Public License -// along with cvBlob. If not, see . - -namespace OpenCvSharp.Blob -{ - /// - /// Struct that contain information about one track. - /// - public class CvTrack - { - /// - /// Track identification number. - /// - public int Id { get; set; } - - /// - /// Label assigned to the blob related to this track. - /// - public int Label { get; set; } - - /// - /// X min. - /// - public int MinX { get; set; } - /// - /// X max. - /// - public int MaxX { get; set; } - /// - /// Y min. - /// - public int MinY { get; set; } - /// - /// Y max. - /// - public int MaxY { get; set; } - - /// - /// Centroid. - /// - public Point2d Centroid { get; set; } - - /// - /// Indicates how much frames the object has been in scene. - /// - public int LifeTime { get; set; } - /// - /// Indicates number of frames that has been active from last inactive period. - /// - public int Active { get; set; } - /// - /// Indicates number of frames that has been missing. - /// - public int Inactive { get; set; } - } -} diff --git a/src/OpenCvSharp.Blob/CvTracks.cs b/src/OpenCvSharp.Blob/CvTracks.cs deleted file mode 100644 index 7c017e162..000000000 --- a/src/OpenCvSharp.Blob/CvTracks.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -// Copyright (C) 2007 by Cristóbal Carnero Liñán -// grendel.ccl@gmail.com -// -// This file is part of cvBlob. -// -// cvBlob is free software: you can redistribute it and/or modify -// it under the terms of the Lesser GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cvBlob is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Lesser GNU General Public License for more details. -// -// You should have received a copy of the Lesser GNU General Public License -// along with cvBlob. If not, see . - -namespace OpenCvSharp.Blob -{ - /// - /// - /// - public class CvTracks : Dictionary - { - /// - /// - /// - public CvTracks() - { - } - - #region Render - - /// - /// Prints tracks information. - /// - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - public void Render(Mat imgSource, Mat imgDest) - { - Render(imgSource, imgDest, RenderTracksMode.Id, Scalar.Green); - } - - /// - /// Prints tracks information. - /// - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_TRACK_RENDER_ID. - public void Render(Mat imgSource, Mat imgDest, RenderTracksMode mode) - { - Render(imgSource, imgDest, mode, Scalar.Green); - } - - /// - /// Prints tracks information. - /// - /// Input image (depth=IPL_DEPTH_8U and num. channels=3). - /// Output image (depth=IPL_DEPTH_8U and num. channels=3). - /// Render mode. By default is CV_TRACK_RENDER_ID. - /// - /// - /// - /// - public void Render(Mat imgSource, Mat imgDest, RenderTracksMode mode, Scalar textColor, - HersheyFonts fontFace = HersheyFonts.HersheySimplex, double fontScale = 1d, int thickness = 1) - { - if (imgSource == null) - throw new ArgumentNullException(nameof(imgSource)); - if (imgDest == null) - throw new ArgumentNullException(nameof(imgDest)); - if (imgDest.Type() != MatType.CV_8UC3) - throw new ArgumentException("imgDest.Depth != U8 || imgDest.NChannels != 3"); - - if (mode != RenderTracksMode.None) - { - foreach (KeyValuePair kv in this) - { - int key = kv.Key; - CvTrack value = kv.Value; - - if ((mode & RenderTracksMode.Id) == RenderTracksMode.Id) - { - if (value.Inactive == 0) - { - Cv2.PutText(imgDest, key.ToString(), (Point)value.Centroid, - fontFace, fontScale, textColor, thickness); - } - } - if ((mode & RenderTracksMode.BoundingBox) == RenderTracksMode.BoundingBox) - { - if (value.Inactive > 0) - Cv2.Rectangle( - imgDest, - new Point(value.MinX, value.MinY), - new Point(value.MaxX - 1, value.MaxY - 1), - new Scalar(50, 0, 0)); - else - Cv2.Rectangle( - imgDest, - new Point(value.MinX, value.MinY), - new Point(value.MaxX - 1, value.MaxY - 1), - new Scalar(255, 0, 0)); - } - } - } - } - - #endregion - - #region ToString - - /// - /// - /// - /// - public override string ToString() - { - StringBuilder builder = new StringBuilder(); - foreach (KeyValuePair kv in this) - { - CvTrack value = kv.Value; - - builder.AppendFormat("Track {0}", value).AppendLine(); - if (value.Inactive > 0) - builder.AppendFormat(" - Inactive for {0} frames", value.Inactive).AppendLine(); - else - builder.AppendFormat(" - Associated with blobs {0}", value.Label).AppendLine(); - builder.AppendFormat(" - Lifetime {0}", value.LifeTime).AppendLine(); - builder.AppendFormat(" - Active {0}", value.Active).AppendLine(); - builder.AppendFormat(" - Bounding box: ({0},{1}) - ({2}, {3})", - value.MinX, value.MinY, value.MaxX, value.MaxY).AppendLine(); - builder.AppendFormat(" - Centroid: ({0}, {1})", value.Centroid.X, value.Centroid.Y).AppendLine(); - builder.AppendLine(); - } - return builder.ToString(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/OpenCvSharp.Blob/Key.snk b/src/OpenCvSharp.Blob/Key.snk deleted file mode 100644 index a1e033087..000000000 Binary files a/src/OpenCvSharp.Blob/Key.snk and /dev/null differ diff --git a/src/OpenCvSharp.Blob/LabelData.cs b/src/OpenCvSharp.Blob/LabelData.cs deleted file mode 100644 index 2b59b98b8..000000000 --- a/src/OpenCvSharp.Blob/LabelData.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; - -namespace OpenCvSharp.Blob -{ - /// - /// Label values for each pixel - /// - public class LabelData - { - private Size size; - private int[,] values; - - /// - /// Label value - /// - public int[,] Values - { - get { return values; } - } - - /// - /// Image sizw - /// - public Size Size - { - get { return size; } - } - - /// - /// Row length - /// - public int Rows - { - get { return Values.GetLength(0); } - } - - /// - /// Column Length - /// - public int Cols - { - get { return Values.GetLength(1); } - } - - /// - /// - /// - /// - /// - public LabelData(int rows, int cols) - { - values = new int[rows, cols]; - size = new Size(cols, rows); - } - - /// - /// - /// - /// - public LabelData(int[,] values) - { - values = (int[,]) values.Clone(); - size.Height = values.GetLength(0); - size.Width = values.GetLength(1); - } - - /// - /// - /// - /// - /// - public LabelData(int[,] values, Rect roi) - { - values = (int[,]) values.Clone(); - } - - /// - /// - /// - /// - /// - /// - public int RawGetLabel(int row, int col) - { - return Values[row, col]; - } - - /// - /// - /// - /// - /// - /// - public void RawSetLabel(int row, int col, int value) - { - Values[row, col] = value; - } - - /// - /// - /// - /// - /// - /// - public int this[int row, int col] - { - get { return Values[row, col]; } - set { Values[row, col] = value; } - } - - /// - /// - /// - public void DebugShow() - { - using (Mat img = Mat.Zeros(Rows, Cols, MatType.CV_8UC1)) - { - var indexer = img.GetGenericIndexer(); - for (int r = 0; r < Rows; r++) - { - for (int c = 0; c < Cols; c++) - { - if (Values[r, c] != 0) - indexer[r, c] = 255; - } - } - Window.ShowImages(img); - } - } - - /// - /// Returns deep copied instance of this - /// - /// - public LabelData Clone() - { - return new LabelData((int[,]) Values.Clone()); - } - } -} diff --git a/src/OpenCvSharp.Blob/Labeller.cs b/src/OpenCvSharp.Blob/Labeller.cs deleted file mode 100644 index 3a87c1dc2..000000000 --- a/src/OpenCvSharp.Blob/Labeller.cs +++ /dev/null @@ -1,360 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; - -// Copyright (C) 2007 by Cristóbal Carnero Liñán -// grendel.ccl@gmail.com -// -// This file is part of cvBlob. -// -// cvBlob is free software: you can redistribute it and/or modify -// it under the terms of the Lesser GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// cvBlob is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// Lesser GNU General Public License for more details. -// -// You should have received a copy of the Lesser GNU General Public License -// along with cvBlob. If not, see . - -namespace OpenCvSharp.Blob -{ - /// - /// - /// - internal static class Labeller - { - private static readonly int[,,] MovesE = new int[4, 3, 4] - { - { - {-1, -1, 3, CvBlobConst.CV_CHAINCODE_UP_LEFT}, {0, -1, 0, CvBlobConst.CV_CHAINCODE_UP}, - {1, -1, 0, CvBlobConst.CV_CHAINCODE_UP_RIGHT} - }, - { - {1, -1, 0, CvBlobConst.CV_CHAINCODE_UP_RIGHT}, {1, 0, 1, CvBlobConst.CV_CHAINCODE_RIGHT}, - {1, 1, 1, CvBlobConst.CV_CHAINCODE_DOWN_RIGHT} - }, - { - {1, 1, 1, CvBlobConst.CV_CHAINCODE_DOWN_RIGHT}, {0, 1, 2, CvBlobConst.CV_CHAINCODE_DOWN}, - {-1, 1, 2, CvBlobConst.CV_CHAINCODE_DOWN_LEFT} - }, - { - {-1, 1, 2, CvBlobConst.CV_CHAINCODE_DOWN_LEFT}, {-1, 0, 3, CvBlobConst.CV_CHAINCODE_LEFT}, - {-1, -1, 3, CvBlobConst.CV_CHAINCODE_UP_LEFT} - } - }; - - private static readonly int[,,] MovesI = new int[4, 3, 4] - { - { - {1, -1, 3, CvBlobConst.CV_CHAINCODE_UP_RIGHT}, {0, -1, 0, CvBlobConst.CV_CHAINCODE_UP}, - {-1, -1, 0, CvBlobConst.CV_CHAINCODE_UP_LEFT} - }, - { - {-1, -1, 0, CvBlobConst.CV_CHAINCODE_UP_LEFT}, {-1, 0, 1, CvBlobConst.CV_CHAINCODE_LEFT}, - {-1, 1, 1, CvBlobConst.CV_CHAINCODE_DOWN_LEFT} - }, - { - {-1, 1, 1, CvBlobConst.CV_CHAINCODE_DOWN_LEFT}, {0, 1, 2, CvBlobConst.CV_CHAINCODE_DOWN}, - {1, 1, 2, CvBlobConst.CV_CHAINCODE_DOWN_RIGHT} - }, - { - {1, 1, 2, CvBlobConst.CV_CHAINCODE_DOWN_RIGHT}, {1, 0, 3, CvBlobConst.CV_CHAINCODE_RIGHT}, - {1, -1, 3, CvBlobConst.CV_CHAINCODE_UP_RIGHT} - } - }; - - /// - /// Value of invalid pixel. - /// -1 == uint.MaxValue - /// - private const int MarkerValue = -1; - - /// - /// - /// - /// - /// - /// - public static int Perform(Mat img, CvBlobs blobs) - { - if (img == null) - throw new ArgumentNullException(nameof(img)); - if (blobs == null) - throw new ArgumentNullException(nameof(blobs)); - if (img.Type() != MatType.CV_8UC1) - throw new ArgumentException("'img' must be a 1-channel U8 image."); - - LabelData labels = blobs.Labels; - if (labels == null) - throw new ArgumentException(""); - //if(labels.GetLength(0) != h || labels.GetLength(1) != w) - if (labels.Rows != img.Height || labels.Cols != img.Width) - throw new ArgumentException("img.Size != labels' size"); - - int numPixels = 0; - blobs.Clear(); - - int w = img.Cols; - int h = img.Rows; - int step = (int)img.Step(); - byte[] imgIn; - unsafe - { - byte* imgInPtr = (byte*)img.Data; - if ((long) h * step > Int32.MaxValue) - throw new ArgumentException("Too big image (image data > 2^31)"); - int length = h * step; - imgIn = new byte[length]; - Marshal.Copy(new IntPtr(imgInPtr), imgIn, 0, imgIn.Length); - } - int label = 0; - int lastLabel = 0; - CvBlob lastBlob = null; - - - for (int y = 0; y < h; y++) - { - for (int x = 0; x < w; x++) - { - if (imgIn[x + y * step] == 0) - continue; - - bool labeled = labels[y, x] != 0; - if (!labeled && ((y == 0) || (imgIn[x + (y - 1) * step] == 0))) - { - labeled = true; - - // Label contour. - label++; - if (label == MarkerValue) - throw new Exception(); - - labels[y, x] = label; - numPixels++; - - // XXX This is not necessary at all. I only do this for consistency. - if (y > 0) - labels[y - 1, x] = MarkerValue; - - CvBlob blob = new CvBlob(label, x, y); - blobs.Add(label, blob); - lastLabel = label; - lastBlob = blob; - - blob.Contour.StartingPoint = new Point(x, y); - int direction = 1; - int xx = x; - int yy = y; - bool contourEnd = false; - - do - { - for (int numAttempts = 0; numAttempts < 3; numAttempts++) - { - bool found = false; - for (int i = 0; i < 3; i++) - { - int nx = xx + MovesE[direction, i, 0]; - int ny = yy + MovesE[direction, i, 1]; - if ((nx < w) && (nx >= 0) && (ny < h) && (ny >= 0)) - { - if (imgIn[nx + ny * step] != 0) - { - found = true; - blob.Contour.ChainCode.Add((CvChainCode)MovesE[direction, i, 3]); - xx = nx; - yy = ny; - direction = MovesE[direction, i, 2]; - break; - } - labels[ny, nx] = MarkerValue; - } - } - - if (!found) - direction = (direction + 1) % 4; - else - { - if (labels[yy, xx] != label) - { - labels[yy, xx] = label; - numPixels++; - - if (xx < blob.MinX) - blob.MinX = xx; - else if (xx > blob.MaxX) - blob.MaxX = xx; - if (yy < blob.MinY) - blob.MinY = yy; - else if (yy > blob.MaxY) - blob.MaxY = yy; - - blob.Area++; - blob.M10 += xx; - blob.M01 += yy; - blob.M11 += xx * yy; - blob.M20 += xx * xx; - blob.M02 += yy * yy; - } - break; - } - - contourEnd = ((xx == x) && (yy == y) && (direction == 1)); - if (contourEnd) - break; - } - } while (!contourEnd); - - } - - if ((y + 1 < h) && (imgIn[x + (y + 1) * step] == 0) && (labels[y + 1, x] == 0)) - { - labeled = true; - - // Label internal contour - int l; - CvBlob blob; - - if (labels[y, x] == 0) - { - l = labels[y, x - 1]; - labels[y, x] = l; - numPixels++; - - if (l == lastLabel) - blob = lastBlob; - else - { - blob = blobs[l]; - lastLabel = l; - lastBlob = blob; - } - if (blob == null) - throw new Exception(); - blob.Area++; - blob.M10 += x; - blob.M01 += y; - blob.M11 += x * y; - blob.M20 += x * x; - blob.M02 += y * y; - } - else - { - l = labels[y, x]; - if (l == lastLabel) - blob = lastBlob; - else - { - blob = blobs[l]; - lastLabel = l; - lastBlob = blob; - } - } - - if (blob == null) - throw new Exception(); - - // XXX This is not necessary (I believe). I only do this for consistency. - labels[y + 1, x] = MarkerValue; - var contour = new CvContourChainCode - { - StartingPoint = new Point(x, y) - }; - - int direction = 3; - int xx = x; - int yy = y; - - do - { - for (int numAttempts = 0; numAttempts < 3; numAttempts++) - { - bool found = false; - - for (int i = 0; i < 3; i++) - { - int nx = xx + MovesI[direction, i, 0]; - int ny = yy + MovesI[direction, i, 1]; - if (imgIn[nx + ny * step] != 0) - { - found = true; - contour.ChainCode.Add((CvChainCode)MovesI[direction, i, 3]); - xx = nx; - yy = ny; - direction = MovesI[direction, i, 2]; - break; - } - labels[ny, nx] = MarkerValue; - } - - if (!found) - direction = (direction + 1) % 4; - else - { - if (labels[yy, xx] == 0) - { - labels[yy, xx] = l; - numPixels++; - - blob.Area++; - blob.M10 += xx; - blob.M01 += yy; - blob.M11 += xx * yy; - blob.M20 += xx * xx; - blob.M02 += yy * yy; - } - break; - } - } - } while (!(xx == x && yy == y)); - - blob.InternalContours.Add(contour); - } - - //else if (!imageOut(x, y)) - if (!labeled) - { - // Internal pixel - int l = labels[y, x - 1]; - labels[y, x] = l; - numPixels++; - - CvBlob blob; - if (l == lastLabel) - blob = lastBlob; - else - { - blob = blobs[l]; - lastLabel = l; - lastBlob = blob; - } - if (blob == null) - throw new Exception(); - blob.Area++; - blob.M10 += x; - blob.M01 += y; - blob.M11 += x * y; - blob.M20 += x * x; - blob.M02 += y * y; - } - } - } - - - foreach (var kv in blobs) - { - kv.Value.SetMoments(); - } - - GC.KeepAlive(img); - - return numPixels; - } - } -} diff --git a/src/OpenCvSharp.Blob/OpenCvSharp.Blob.csproj b/src/OpenCvSharp.Blob/OpenCvSharp.Blob.csproj deleted file mode 100644 index a0cd80a2b..000000000 --- a/src/OpenCvSharp.Blob/OpenCvSharp.Blob.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - - netstandard2.0;net20;net40;net461 - true - true - OpenCvSharp.Blob - Key.snk - true - true - OpenCvSharp.Blob - false - false - false - - - - - - - - - - - - - - - - - - - - - - $(DefineConstants);DOTNET_FRAMEWORK; - - - - $(DefineConstants);DOTNET_FRAMEWORK; - - - - $(DefineConstants);DOTNET_FRAMEWORK; - - - - $(DefineConstants);netstandard20 - - - diff --git a/src/OpenCvSharp.Blob/Properties/AssemblyInfo.cs b/src/OpenCvSharp.Blob/Properties/AssemblyInfo.cs deleted file mode 100644 index 76cdbd357..000000000 --- a/src/OpenCvSharp.Blob/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenCvSharp.Blob")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("82afda65-515e-4ec0-a415-77d8a6711508")] diff --git a/src/OpenCvSharp.Blob/ProximityMatrix.cs b/src/OpenCvSharp.Blob/ProximityMatrix.cs deleted file mode 100644 index 686eda344..000000000 --- a/src/OpenCvSharp.Blob/ProximityMatrix.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenCvSharp.Blob -{ - internal class ProximityMatrix - { - private readonly int[] close; - private readonly int nBlobs; - private readonly int nTtacks; - - public ProximityMatrix(int nBlobs, int nTracks) - { - this.nBlobs = nBlobs; - this.nTtacks = nTracks; - this.close = new int[(nBlobs + 2) * (nTracks + 2)]; - AB = new ABIndexer(this); - AT = new ATIndexer(this); - IB = new IBIndexer(this); - IT = new ITIndexer(this); - } - - public int this[int blob, int track] - { - get - { - return close[((blob) + (track) * (nBlobs + 2))]; - } - set - { - close[((blob) + (track) * (nBlobs + 2))] = value; - } - } - - #region Indexer - public abstract class Indexer - { - protected ProximityMatrix matrix; - protected Indexer(ProximityMatrix matrix) - { - this.matrix = matrix; - } - public abstract int this[int index] { get; set; } - } - public class ABIndexer : Indexer - { - internal ABIndexer(ProximityMatrix matrix) - : base(matrix) - { - } - public override int this[int label] - { - get { return matrix[label, matrix.nTtacks]; } - set { matrix[label, matrix.nTtacks] = value; } - } - } - public class ATIndexer : Indexer - { - internal ATIndexer(ProximityMatrix matrix) - : base(matrix) - { - } - public override int this[int id] - { - get { return matrix[matrix.nBlobs, id]; } - set { matrix[matrix.nBlobs, id] = value; } - } - } - public class IBIndexer : Indexer - { - internal IBIndexer(ProximityMatrix matrix) - : base(matrix) - { - } - public override int this[int label] - { - get { return matrix[label, matrix.nTtacks + 1]; } - set { matrix[label, matrix.nTtacks + 1] = value; } - } - } - public class ITIndexer : Indexer - { - internal ITIndexer(ProximityMatrix matrix) - : base(matrix) - { - } - public override int this[int id] - { - get { return matrix[matrix.nBlobs + 1, id]; } - set { matrix[matrix.nBlobs + 1, id] = value; } - } - } - - public ABIndexer AB { get; private set; } - public ATIndexer AT { get; private set; } - public IBIndexer IB { get; private set; } - public ITIndexer IT { get; private set; } - #endregion - } -} diff --git a/src/OpenCvSharp.Blob/ReadMe.txt b/src/OpenCvSharp.Blob/ReadMe.txt deleted file mode 100644 index 0c8268a9d..000000000 --- a/src/OpenCvSharp.Blob/ReadMe.txt +++ /dev/null @@ -1,3 +0,0 @@ -This project "OpenCvSharp.Blob" is a wrapper of cvblob (http://code.google.com/p/cvblob/). - -cvblob and OpenCvSharp are licensed using the LGPL (http://www.gnu.org/licenses/lgpl.html). diff --git a/src/OpenCvSharp.Blob/RenderBlobsMode.cs b/src/OpenCvSharp.Blob/RenderBlobsMode.cs deleted file mode 100644 index 4923cc2fe..000000000 --- a/src/OpenCvSharp.Blob/RenderBlobsMode.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenCvSharp.Blob -{ - /// - /// Render mode of cvRenderBlobs - /// - [Flags] - public enum RenderBlobsMode : ushort - { - /// - /// No flags (=0) - /// - None = 0, - - /// - /// Render each blog with a different color. - /// [CV_BLOB_RENDER_COLOR] - /// - Color = CvBlobConst.CV_BLOB_RENDER_COLOR, - - /// - /// Render centroid. - /// CV_BLOB_RENDER_CENTROID] - /// - Centroid = CvBlobConst.CV_BLOB_RENDER_CENTROID, - - /// - /// Render bounding box. - /// [CV_BLOB_RENDER_BOUNDING_BOX] - /// - BoundingBox = CvBlobConst.CV_BLOB_RENDER_BOUNDING_BOX, - - /// - /// Render angle. - /// [CV_BLOB_RENDER_ANGLE] - /// - Angle = CvBlobConst.CV_BLOB_RENDER_ANGLE, - - /// - /// Print blob data to log out. - /// [CV_BLOB_RENDER_TO_LOG] - /// - ToLog = CvBlobConst.CV_BLOB_RENDER_TO_LOG, - - /// - /// Print blob data to std out. - /// [CV_BLOB_RENDER_TO_STD] - /// - ToStd = CvBlobConst.CV_BLOB_RENDER_TO_STD, - } -} diff --git a/src/OpenCvSharp.Blob/RenderTracksMode.cs b/src/OpenCvSharp.Blob/RenderTracksMode.cs deleted file mode 100644 index 1ce026257..000000000 --- a/src/OpenCvSharp.Blob/RenderTracksMode.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenCvSharp.Blob -{ - /// - /// Render mode of cvRenderTracks - /// - [Flags] - public enum RenderTracksMode : ushort - { - /// - /// No flags - /// [0] - /// - None = 0, - - /// - /// Print the ID of each track in the image. - /// [CV_TRACK_RENDER_ID] - /// - Id = CvBlobConst.CV_TRACK_RENDER_ID, - - /// - /// Draw bounding box of each track in the image. \see cvRenderTracks - /// [CV_TRACK_RENDER_BOUNDING_BOX] - /// - BoundingBox = CvBlobConst.CV_TRACK_RENDER_BOUNDING_BOX, - } -} diff --git a/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.cs b/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.cs index 8dc8087a2..4f7833ffd 100644 --- a/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.cs +++ b/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.cs @@ -4,40 +4,46 @@ namespace OpenCvSharp.DebuggerVisualizers { - /// - /// - /// public partial class ImageViewer : Form { private readonly Bitmap bitmap; - /// - /// - /// public ImageViewer() { InitializeComponent(); } - /// - /// - /// - /// public ImageViewer(MatProxy proxy) : this() { bitmap = proxy.CreateBitmap(); } - /// - /// + /// + /// 仅仅用于开发目的。 /// - /// + /// + /// デバッグのみを目的としています。 + /// + /// + public ImageViewer(string imgFile) + : this() + { + bitmap = new Bitmap(imgFile); + } + + private void DisposeBitmap() + { + bitmap?.Dispose(); + } + protected override void OnLoad(EventArgs e) { base.OnLoad(e); - SetClientSize(new System.Drawing.Size(bitmap.Width, bitmap.Height)); + var ratio = SetClientSize(new System.Drawing.Size(bitmap.Width, bitmap.Height)); + DisplayRatio(ratio); + pictureBox.Image = bitmap; } @@ -45,22 +51,33 @@ protected override void OnLoad(EventArgs e) /// ClientSizeを画面からはみ出ない大きさに調整して設定する. /// /// - private void SetClientSize(System.Drawing.Size size) + private double SetClientSize(System.Drawing.Size size) { var screenSize = Screen.PrimaryScreen.Bounds.Size; - if (size.Width > screenSize.Width) - { - double ratio = (double) screenSize.Width/size.Width; - size.Width = Convert.ToInt32(size.Width*ratio); - size.Height = Convert.ToInt32(size.Height*ratio); - } - if (size.Height > screenSize.Height) - { - double ratio = (double) screenSize.Height/size.Height; - size.Width = Convert.ToInt32(size.Width*ratio); - size.Height = Convert.ToInt32(size.Height*ratio); - } + var ratioX = (double)screenSize.Width / size.Width; + var ratioY = (double)screenSize.Height / size.Height; + var ratio = Math.Max(ratioX, ratioY); + ratio = ReformRatio(ratio); + size.Width = Convert.ToInt32(size.Width * ratio); + size.Height = Convert.ToInt32(size.Height * ratio); ClientSize = size; + pictureBox.Size = size; + return ratio; + } + + private double ReformRatio(double ratio) + { + var v1 = ratio; + var lg2 = Math.Log(v1, 2); + var lgz = Math.Floor(lg2); + var pw = lgz == lg2 ? lgz - 1 : lgz; + var r = Math.Pow(2, pw); + return r; + } + + private void DisplayRatio(double ratio) + { + Text = $@"ImageViewer Zoom: {ratio:P1}"; } } } diff --git a/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.designer.cs b/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.designer.cs index 2074dd920..331890f0d 100644 --- a/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.designer.cs +++ b/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.designer.cs @@ -13,9 +13,10 @@ partial class ImageViewer /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (components != null)) + if (disposing) { - components.Dispose(); + components?.Dispose(); + DisposeBitmap(); } base.Dispose(disposing); } @@ -28,35 +29,32 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.pictureBox = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); - this.SuspendLayout(); - // - // pictureBox - // - this.pictureBox.BackColor = System.Drawing.Color.Black; - this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBox.Location = new System.Drawing.Point(0, 0); - this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(384, 263); - this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBox.TabIndex = 0; - this.pictureBox.TabStop = false; - // - // ImageViewer - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(384, 263); - this.Controls.Add(this.pictureBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ImageViewer"; - this.Text = "ImageViewer"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + this.pictureBox = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox + // + this.pictureBox.BackColor = System.Drawing.Color.Black; + this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox.Location = new System.Drawing.Point(0, 0); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(384, 263); + this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox.TabIndex = 0; + this.pictureBox.TabStop = false; + // + // ImageViewer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScroll = true; + this.ClientSize = new System.Drawing.Size(384, 263); + this.Controls.Add(this.pictureBox); + this.Name = "ImageViewer"; + this.Text = "ImageViewer"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.ResumeLayout(false); } @@ -66,4 +64,4 @@ private void InitializeComponent() } -} \ No newline at end of file +} diff --git a/tool/OpenCvSharp.ReleaseMaker/Properties/Resources.resx b/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.resx similarity index 90% rename from tool/OpenCvSharp.ReleaseMaker/Properties/Resources.resx rename to src/OpenCvSharp.DebuggerVisualizers/ImageViewer.resx index af7dbebba..1af7de150 100644 --- a/tool/OpenCvSharp.ReleaseMaker/Properties/Resources.resx +++ b/src/OpenCvSharp.DebuggerVisualizers/ImageViewer.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/src/OpenCvSharp.DebuggerVisualizers/MatDebuggerVisualizer.cs b/src/OpenCvSharp.DebuggerVisualizers/MatDebuggerVisualizer.cs index f2b57b3ba..26833207d 100644 --- a/src/OpenCvSharp.DebuggerVisualizers/MatDebuggerVisualizer.cs +++ b/src/OpenCvSharp.DebuggerVisualizers/MatDebuggerVisualizer.cs @@ -11,18 +11,17 @@ public class MatDebuggerVisualizer : DialogDebuggerVisualizer protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { // MatProxyが送られてくるはず - using (var proxy = objectProvider.GetObject() as MatProxy) + var proxy = objectProvider.GetObject() as MatProxy; + if (proxy is null) { - if (proxy == null) - { - throw new ArgumentException(); - } - // Formに表示 - using (var form = new ImageViewer(proxy)) - { - windowService.ShowDialog(form); - } - } + throw new ArgumentException(); + } + + // Formに表示 + using (var form = new ImageViewer(proxy)) + { + windowService.ShowDialog(form); + } } } } diff --git a/src/OpenCvSharp.DebuggerVisualizers/MatObjectSource.cs b/src/OpenCvSharp.DebuggerVisualizers/MatObjectSource.cs index f8ae2e238..160921786 100644 --- a/src/OpenCvSharp.DebuggerVisualizers/MatObjectSource.cs +++ b/src/OpenCvSharp.DebuggerVisualizers/MatObjectSource.cs @@ -15,4 +15,4 @@ public override void GetData(object target, Stream outgoingData) bf.Serialize(outgoingData, new MatProxy((Mat)target)); } } -} \ No newline at end of file +} diff --git a/src/OpenCvSharp.DebuggerVisualizers/MatProxy.cs b/src/OpenCvSharp.DebuggerVisualizers/MatProxy.cs index 433dd93be..c4109308f 100644 --- a/src/OpenCvSharp.DebuggerVisualizers/MatProxy.cs +++ b/src/OpenCvSharp.DebuggerVisualizers/MatProxy.cs @@ -9,24 +9,19 @@ namespace OpenCvSharp.DebuggerVisualizers /// 送る際に、このProxyに表示に必要なシリアライズ可能なデータを詰めて送り、受信側で復元する。 /// [Serializable] - public class MatProxy : IDisposable + public class MatProxy { public byte[] ImageData { get; private set; } public MatProxy(Mat image) { - ImageData = image.ToBytes(".png"); - } - - public void Dispose() - { - ImageData = null; + ImageData = image.ToBytes(); } public Bitmap CreateBitmap() { - if (ImageData == null) - throw new Exception("ImageData == null"); + if (ImageData is null) + throw new Exception("ImageData is null"); using (var stream = new MemoryStream(ImageData)) { @@ -34,4 +29,4 @@ public Bitmap CreateBitmap() } } } -} \ No newline at end of file +} diff --git a/src/OpenCvSharp.DebuggerVisualizers/OpenCvSharp.DebuggerVisualizers.csproj b/src/OpenCvSharp.DebuggerVisualizers/OpenCvSharp.DebuggerVisualizers.csproj index d0e9d29a9..f632b1b3c 100644 --- a/src/OpenCvSharp.DebuggerVisualizers/OpenCvSharp.DebuggerVisualizers.csproj +++ b/src/OpenCvSharp.DebuggerVisualizers/OpenCvSharp.DebuggerVisualizers.csproj @@ -9,7 +9,7 @@ Properties OpenCvSharp.DebuggerVisualizers OpenCvSharp.DebuggerVisualizers - v4.5 + v4.8 512 @@ -68,10 +68,15 @@ + + .editorconfig + - + + ImageViewer.cs + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 16, 14 - - - 130, 14 - - - 330, 14 - - \ No newline at end of file diff --git a/tool/OpenCvSharp.ReleaseMaker/OpenCvSharp.ReleaseMaker.csproj b/tool/OpenCvSharp.ReleaseMaker/OpenCvSharp.ReleaseMaker.csproj index c2649d87a..41f1d5ad4 100644 --- a/tool/OpenCvSharp.ReleaseMaker/OpenCvSharp.ReleaseMaker.csproj +++ b/tool/OpenCvSharp.ReleaseMaker/OpenCvSharp.ReleaseMaker.csproj @@ -1,96 +1,8 @@ - - + + - Debug - AnyCPU - 9.0.21022 - 2.0 - {E2C8C528-B7C7-40AF-BB7F-1147A41E2E23} - WinExe - Properties - OpenCvSharp.ReleaseMaker - OpenCvSharp.ReleaseMaker - v4.7.2 - 512 - - - 3.5 - - - + Exe + net6.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - false - bin\Release\ - TRACE - prompt - 4 - false - - - - - - 3.5 - - - - - - - - Form - - - MainForm.cs - - - - - MainForm.cs - Designer - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - \ No newline at end of file + + diff --git a/tool/OpenCvSharp.ReleaseMaker/Packer.cs b/tool/OpenCvSharp.ReleaseMaker/Packer.cs new file mode 100644 index 000000000..2726467bf --- /dev/null +++ b/tool/OpenCvSharp.ReleaseMaker/Packer.cs @@ -0,0 +1,292 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; + +namespace OpenCvSharp.ReleaseMaker; + +public static class Packer +{ + private static readonly IReadOnlyDictionary dllFiles = new Dictionary + { + ["net48"] = new[] + { + @"OpenCvSharp\bin\Release\net48\OpenCvSharp.dll", + @"OpenCvSharp\bin\Release\net48\OpenCvSharp.dll.config", + @"OpenCvSharp\bin\Release\net48\OpenCvSharp.pdb", + @"OpenCvSharp.Extensions\bin\Release\net48\OpenCvSharp.Extensions.dll", + @"OpenCvSharp.Extensions\bin\Release\net48\OpenCvSharp.Extensions.pdb", + @"OpenCvSharp.WpfExtensions\bin\Release\net48\OpenCvSharp.WpfExtensions.dll", + @"OpenCvSharp.WpfExtensions\bin\Release\net48\OpenCvSharp.WpfExtensions.pdb", + }, + ["netstandard2.0"] = new[] + { + @"OpenCvSharp\bin\Release\netstandard2.0\OpenCvSharp.dll", + @"OpenCvSharp\bin\Release\netstandard2.0\OpenCvSharp.dll.config", + @"OpenCvSharp\bin\Release\netstandard2.0\OpenCvSharp.pdb", + @"OpenCvSharp.Extensions\bin\Release\netstandard2.0\OpenCvSharp.Extensions.dll", + @"OpenCvSharp.Extensions\bin\Release\netstandard2.0\OpenCvSharp.Extensions.pdb", + }, + ["netstandard2.1"] = new[] + { + @"OpenCvSharp\bin\Release\netstandard2.1\OpenCvSharp.dll", + @"OpenCvSharp\bin\Release\netstandard2.1\OpenCvSharp.dll.config", + @"OpenCvSharp\bin\Release\netstandard2.1\OpenCvSharp.pdb", + @"OpenCvSharp.Extensions\bin\Release\netstandard2.1\OpenCvSharp.Extensions.dll", + @"OpenCvSharp.Extensions\bin\Release\netstandard2.1\OpenCvSharp.Extensions.pdb", + }, + ["net6.0"] = new[] + { + @"OpenCvSharp\bin\Release\net6.0\OpenCvSharp.dll", + @"OpenCvSharp\bin\Release\net6.0\OpenCvSharp.dll.config", + @"OpenCvSharp\bin\Release\net6.0\OpenCvSharp.pdb", + @"OpenCvSharp.Extensions\bin\Release\net6.0\OpenCvSharp.Extensions.dll", + @"OpenCvSharp.Extensions\bin\Release\net6.0\OpenCvSharp.Extensions.pdb", + @"OpenCvSharp.WpfExtensions\bin\Release\net6.0-windows\OpenCvSharp.WpfExtensions.dll", + @"OpenCvSharp.WpfExtensions\bin\Release\net6.0-windows\OpenCvSharp.WpfExtensions.pdb", + }, + }; + + private const string DebuggerVisualizerPath = @"OpenCvSharp.DebuggerVisualizers\bin\Release\OpenCvSharp.DebuggerVisualizers.dll"; + + private static readonly string[] xmlFiles = { + @"OpenCvSharp\bin\Release\net48\OpenCvSharp.xml", + @"OpenCvSharp.Extensions\bin\Release\net48\OpenCvSharp.Extensions.xml", + @"OpenCvSharp.WpfExtensions\OpenCvSharp.WpfExtensions.xml", + }; + + private static readonly IReadOnlyDictionary architectures = new Dictionary + { + ["win"] = new[] { "x86", "x64" }, + //["uwp"] = new[] { "x86", "x64", "ARM" }, + }; + + private static readonly IReadOnlySet ignoredExt = new[]{ + ".bak", + ".user", + ".suo", + ".git", + ".gitignore", + }.ToHashSet(); + private static readonly IReadOnlySet ignoredDir = new[]{ + ".git", + "bin", + "obj", + ".vs", + ".nuget", + "packages", + }.ToHashSet(); + + private static IReadOnlyDictionary UwpNativeDllDirectories(string version) + { + version = version.Replace(".", ""); + return new Dictionary + { + ["x86"] = @$"opencv_files\opencv{version}_uwp_x86\x86\vc17\bin", + ["x64"] = @$"opencv_files\opencv{version}_uwp_x64\x64\vc17\bin", + ["ARM"] = @$"opencv_files\opencv{version}_uwp_ARM\x86\vc17\bin", + }; + } + + private static IReadOnlyList UwpNativeDlls(string version) + { + version = version.Replace(".", ""); + return new[] + { + $"opencv_world{version}.dll", + $"opencv_img_hash{version}.dll" + }; + } + + /// + /// Make + /// + /// + /// + /// e.g. 4.5.1 + public static void Pack(string srcDir, string dstDir, string opencvVersion) + { + MakeBinaryPackage(srcDir, dstDir, opencvVersion); + MakeSamplePackage(srcDir, dstDir, opencvVersion); + } + + /// + /// Create a zip package that contains DLL files + /// + /// + /// + /// + private static void MakeBinaryPackage(string dir, string dirDst, string opencvVersion) + { + var dirSrc = Path.Combine(dir, "src"); + + var dstFileName = Path.Combine(dirDst, GetBinaryDstDirName(opencvVersion)) + ".zip"; + using var zipStream = File.OpenWrite(dstFileName); + using var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create, false); + + // net48, net6.0といったplatformごとにDLLを選択 + foreach (var (frameworkName, dllFileNames) in dllFiles) + { + foreach (var dllFileName in dllFileNames) + { + var dllPath = Path.Combine(dirSrc, dllFileName); + zipArchive.CreateEntryFromFile( + dllPath, + Path.Combine("ManagedLib", frameworkName, Path.GetFileName(dllPath)), + CompressionLevel.Optimal); + } + } + + // XMLドキュメントコメントを選択 + foreach (var f in xmlFiles) + { + var xmlPath = Path.Combine(dirSrc, f); + if (!File.Exists(xmlPath)) + continue; + zipArchive.CreateEntryFromFile( + xmlPath, + Path.Combine("XmlDoc", Path.GetFileName(xmlPath)), + CompressionLevel.Optimal); + } + + + // OpenCvSharpExtern.dllを、Windows用とUWP用それぞれで、x86/x64それぞれを入れる + foreach (var p in architectures) + { + foreach (var arch in p.Value) + { + var externDir = Path.Combine(dirSrc, "Release"); + if (p.Key == "uwp") + externDir = Path.Combine(externDir, "uwpOpenCvSharpExtern"); + var pfExtern = (arch == "x86") ? "Win32" : "x64"; + externDir = Path.Combine(externDir, pfExtern); + + foreach (var ext in new[] { "dll", "pdb" }) + { + var dstDirectory = Path.Combine("NativeLib", p.Key, arch); + + zipArchive.CreateEntryFromFile( + Path.Combine(externDir, $"OpenCvSharpExtern.{ext}"), + Path.Combine(dstDirectory, $"OpenCvSharpExtern.{ext}")); + } + + // UWPはopencv_world.dll等も入れる + if (p.Key == "uwp") + { + var uwpNativeDllDir = UwpNativeDllDirectories(opencvVersion)[arch]; + uwpNativeDllDir = Path.Combine(dir, uwpNativeDllDir); + foreach (var dllName in UwpNativeDlls(opencvVersion)) + { + var uwpNativeDll = Path.Combine(uwpNativeDllDir, dllName); + var dstDirectory = Path.Combine("NativeLib", "uwp", arch); + zipArchive.CreateEntryFromFile( + uwpNativeDll, + Path.Combine(dstDirectory, dllName)); + } + } + } + } + + // Debugger Visualizerを選択 + { + var dllFileName = Path.Combine(dirSrc, DebuggerVisualizerPath); + var zipFileName = Path.Combine( + "DebuggerVisualizers", Path.GetFileName(DebuggerVisualizerPath)); + zipArchive.CreateEntryFromFile( + dllFileName, + zipFileName); + } + + // テキストを選択 + { + zipArchive.CreateEntryFromFile( + Path.Combine(dir, "LICENSE"), + Path.GetFileName("LICENSE")); + zipArchive.CreateEntryFromFile( + Path.Combine(dir, "README.md"), + Path.GetFileName("README.md")); + } + } + + /// + /// Create a zip package that contains code samples + /// + /// + /// + /// + private static void MakeSamplePackage(string dirSrc, string dirDst, string version) + { + dirSrc = Path.Combine(dirSrc, "samples"); + dirDst = Path.Combine(dirDst, GetSampleDstDirName(version)); + + CopyDirectory(dirSrc, dirDst); + + var dstFileName = dirDst + ".zip"; + File.Delete(dstFileName); + + ZipFile.CreateFromDirectory( + dirDst, + dstFileName, + CompressionLevel.Optimal, + false); + + Directory.Delete(dirDst, true); + } + + private static string GetBinaryDstDirName(string version) + { + var date = DateTime.Now.ToString("yyyyMMdd"); + return $"OpenCvSharp-{version}-{date}"; + } + + private static string GetSampleDstDirName(string version) + { + var date = DateTime.Now.ToString("yyyyMMdd"); + return $"Sample-{version}-{date}"; + } + + /// + /// ディレクトリをコピーする。 + /// .svn bin obj は除外。 + /// + /// コピーするディレクトリ + /// コピー先のディレクトリ + /// http://dobon.net/vb/dotnet/file/copyfolder.html から拝借 + private static void CopyDirectory( + string sourceDirName, string destDirName) + { + // コピー先のディレクトリがあれば削除 + if (Directory.Exists(destDirName)) + { + Directory.Delete(destDirName, true); + } + + // コピー先のディレクトリを作る + Directory.CreateDirectory(destDirName); + File.SetAttributes(destDirName, File.GetAttributes(sourceDirName)); + + // コピー先のディレクトリ名の末尾に"\"をつける + if (destDirName[^1] != Path.DirectorySeparatorChar) + { + destDirName += Path.DirectorySeparatorChar; + } + + // コピー元のディレクトリにあるファイルをコピー + var files = Directory.EnumerateFiles(sourceDirName) + .Where(f => !ignoredExt.Contains(Path.GetExtension(f)?.ToLower())) + .Where(f => Path.GetFileName(f) != "OpenCvSharp.DebuggerVisualizers.dll"); + foreach (var file in files) + { + File.Copy(file, destDirName + Path.GetFileName(file), true); + } + + // コピー元のディレクトリにあるディレクトリについて、再帰的に呼び出す + var dirs = Directory.EnumerateDirectories(sourceDirName) + .Where(d => !ignoredDir.Contains(Path.GetFileName(d))); + foreach (var dir in dirs) + { + CopyDirectory(dir, destDirName + Path.GetFileName(dir)); + } + } +} diff --git a/tool/OpenCvSharp.ReleaseMaker/Program.cs b/tool/OpenCvSharp.ReleaseMaker/Program.cs index 362a598d9..d95a8a393 100644 --- a/tool/OpenCvSharp.ReleaseMaker/Program.cs +++ b/tool/OpenCvSharp.ReleaseMaker/Program.cs @@ -1,19 +1,16 @@ -using System; -using System.Windows.Forms; +namespace OpenCvSharp.ReleaseMaker; -namespace OpenCvSharp.ReleaseMaker +internal class Program { - static class Program + private static void Main(string[] args) { - /// - /// アプリケーションのメイン エントリ ポイントです。 - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new MainForm()); - } + if (args.Length != 3) + return; + + var srcDir = args[0]; + var dstDir = args[1]; + var version = args[2]; + + Packer.Pack(srcDir, dstDir, version); } } diff --git a/tool/OpenCvSharp.ReleaseMaker/Properties/AssemblyInfo.cs b/tool/OpenCvSharp.ReleaseMaker/Properties/AssemblyInfo.cs deleted file mode 100644 index ed2093f61..000000000 --- a/tool/OpenCvSharp.ReleaseMaker/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 -// アセンブリに関連付けられている情報を変更するには、 -// これらの属性値を変更してください。 -[assembly: AssemblyTitle("OpenCvSharp.ReleaseMaker")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenCvSharp.ReleaseMaker")] -[assembly: AssemblyCopyright("Copyright © 2010")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから -// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、 -// その型の ComVisible 属性を true に設定してください。 -[assembly: ComVisible(false)] - -// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です -[assembly: Guid("4af74c3c-4d5c-44e6-9175-af009d755dec")] - -// アセンブリのバージョン情報は、以下の 4 つの値で構成されています: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を -// 既定値にすることができます: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tool/OpenCvSharp.ReleaseMaker/Properties/Resources.Designer.cs b/tool/OpenCvSharp.ReleaseMaker/Properties/Resources.Designer.cs deleted file mode 100644 index 5a6cf1c34..000000000 --- a/tool/OpenCvSharp.ReleaseMaker/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// このコードはツールによって生成されました。 -// ランタイム バージョン:4.0.30319.42000 -// -// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 -// コードが再生成されるときに損失したりします。 -// -//------------------------------------------------------------------------------ - -namespace OpenCvSharp.ReleaseMaker.Properties { - using System; - - - /// - /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 - /// - // このクラスは StronglyTypedResourceBuilder クラスが ResGen - // または Visual Studio のようなツールを使用して自動生成されました。 - // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に - // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenCvSharp.ReleaseMaker.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// すべてについて、現在のスレッドの CurrentUICulture プロパティをオーバーライドします - /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/tool/OpenCvSharp.ReleaseMaker/Properties/Settings.Designer.cs b/tool/OpenCvSharp.ReleaseMaker/Properties/Settings.Designer.cs deleted file mode 100644 index 898914f67..000000000 --- a/tool/OpenCvSharp.ReleaseMaker/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// このコードはツールによって生成されました。 -// ランタイム バージョン:4.0.30319.42000 -// -// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 -// コードが再生成されるときに損失したりします。 -// -//------------------------------------------------------------------------------ - -namespace OpenCvSharp.ReleaseMaker.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/tool/OpenCvSharp.ReleaseMaker/Properties/Settings.settings b/tool/OpenCvSharp.ReleaseMaker/Properties/Settings.settings deleted file mode 100644 index 39645652a..000000000 --- a/tool/OpenCvSharp.ReleaseMaker/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/tool/OpenCvSharp.ReleaseMaker/app.config b/tool/OpenCvSharp.ReleaseMaker/app.config deleted file mode 100644 index 312bb3f26..000000000 --- a/tool/OpenCvSharp.ReleaseMaker/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - -