Compare commits
No commits in common. "master" and "0.1.1" have entirely different histories.
6 changed files with 40 additions and 259 deletions
|
|
@ -1,124 +0,0 @@
|
||||||
name: Build And Publish AIFotoONLUS.Core
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
DOTNET_VERSION: 10.0.x
|
|
||||||
PROJECT_PATH: src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj
|
|
||||||
PACKAGE_OUTPUT_DIR: artifacts/nuget
|
|
||||||
PACKAGE_ARTIFACT_NAME: aifotoonlus-core-nuget
|
|
||||||
NUGET_SOURCE_NAME: forgejo-aifotoonlus
|
|
||||||
NUGET_SOURCE_URL: ${{ vars.AIFOTOONLUS_NUGET_SOURCE_URL || format('{0}/api/packages/{1}/nuget/index.json', github.server_url, vars.AIFOTOONLUS_PACKAGE_OWNER || github.repository_owner) }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: docker
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup .NET
|
|
||||||
uses: actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
||||||
|
|
||||||
- name: Restore
|
|
||||||
run: dotnet restore "${{ env.PROJECT_PATH }}"
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: dotnet build "${{ env.PROJECT_PATH }}" --configuration Release --no-restore /p:GeneratePackageOnBuild=false
|
|
||||||
|
|
||||||
- name: Pack
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
mkdir -p "${{ env.PACKAGE_OUTPUT_DIR }}"
|
|
||||||
|
|
||||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
|
||||||
package_version="${GITHUB_REF_NAME#v}"
|
|
||||||
echo "Packing tag version ${package_version}"
|
|
||||||
dotnet pack "${{ env.PROJECT_PATH }}" \
|
|
||||||
--configuration Release \
|
|
||||||
--output "${{ env.PACKAGE_OUTPUT_DIR }}" \
|
|
||||||
--no-build \
|
|
||||||
/p:PackageVersion="${package_version}"
|
|
||||||
else
|
|
||||||
echo "Packing with project version or MinVer-derived version"
|
|
||||||
dotnet pack "${{ env.PROJECT_PATH }}" \
|
|
||||||
--configuration Release \
|
|
||||||
--output "${{ env.PACKAGE_OUTPUT_DIR }}" \
|
|
||||||
--no-build
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Upload package artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: ${{ env.PACKAGE_ARTIFACT_NAME }}
|
|
||||||
path: ${{ env.PACKAGE_OUTPUT_DIR }}/*.nupkg
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
publish:
|
|
||||||
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
|
|
||||||
needs: build
|
|
||||||
runs-on: docker
|
|
||||||
env:
|
|
||||||
FORGEJO_PACKAGE_USERNAME: ${{ secrets.FORGEJO_PACKAGE_USERNAME }}
|
|
||||||
FORGEJO_PACKAGE_TOKEN: ${{ secrets.FORGEJO_PACKAGE_TOKEN }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Setup .NET
|
|
||||||
uses: actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
||||||
|
|
||||||
- name: Download package artifact
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: ${{ env.PACKAGE_ARTIFACT_NAME }}
|
|
||||||
path: ${{ env.PACKAGE_OUTPUT_DIR }}
|
|
||||||
|
|
||||||
- name: Validate publish secrets
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
if [ -z "${FORGEJO_PACKAGE_USERNAME}" ]; then
|
|
||||||
echo "secrets.FORGEJO_PACKAGE_USERNAME is required"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -z "${FORGEJO_PACKAGE_TOKEN}" ]; then
|
|
||||||
echo "secrets.FORGEJO_PACKAGE_TOKEN is required"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Configure Forgejo NuGet source
|
|
||||||
run: |
|
|
||||||
dotnet nuget add source "${{ env.NUGET_SOURCE_URL }}" \
|
|
||||||
--name "${{ env.NUGET_SOURCE_NAME }}" \
|
|
||||||
--username "${FORGEJO_PACKAGE_USERNAME}" \
|
|
||||||
--password "${FORGEJO_PACKAGE_TOKEN}" \
|
|
||||||
--store-password-in-clear-text
|
|
||||||
|
|
||||||
- name: Publish package to Forgejo NuGet
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
shopt -s nullglob
|
|
||||||
packages=("${{ env.PACKAGE_OUTPUT_DIR }}"/*.nupkg)
|
|
||||||
if [ "${#packages[@]}" -eq 0 ]; then
|
|
||||||
echo "No NuGet packages found in ${{ env.PACKAGE_OUTPUT_DIR }}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
dotnet nuget push "${{ env.PACKAGE_OUTPUT_DIR }}"/*.nupkg \
|
|
||||||
--source "${{ env.NUGET_SOURCE_NAME }}" \
|
|
||||||
--skip-duplicate
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
{
|
|
||||||
"AssemblySemFileVer": "0.1.0.0",
|
|
||||||
"AssemblySemVer": "0.1.0.0",
|
|
||||||
"BranchName": "master",
|
|
||||||
"BuildMetaData": null,
|
|
||||||
"CommitDate": "2026-02-15",
|
|
||||||
"CommitsSinceVersionSource": 11,
|
|
||||||
"EscapedBranchName": "master",
|
|
||||||
"FullBuildMetaData": "Branch.master.Sha.a90da31e531332a4cf0bafe604f89d0e14f3395a",
|
|
||||||
"FullSemVer": "0.1.0-{BranchName}.11",
|
|
||||||
"InformationalVersion": "0.1.0-{BranchName}.11+Branch.master.Sha.a90da31e531332a4cf0bafe604f89d0e14f3395a",
|
|
||||||
"Major": 0,
|
|
||||||
"MajorMinorPatch": "0.1.0",
|
|
||||||
"Minor": 1,
|
|
||||||
"Patch": 0,
|
|
||||||
"PreReleaseLabel": "{BranchName}",
|
|
||||||
"PreReleaseLabelWithDash": "-{BranchName}",
|
|
||||||
"PreReleaseNumber": 11,
|
|
||||||
"PreReleaseTag": "{BranchName}.11",
|
|
||||||
"PreReleaseTagWithDash": "-{BranchName}.11",
|
|
||||||
"SemVer": "0.1.0-{BranchName}.11",
|
|
||||||
"Sha": "a90da31e531332a4cf0bafe604f89d0e14f3395a",
|
|
||||||
"ShortSha": "a90da31",
|
|
||||||
"UncommittedChanges": 7,
|
|
||||||
"VersionSourceSha": "",
|
|
||||||
"WeightedPreReleaseNumber": 11
|
|
||||||
}
|
|
||||||
|
|
@ -8,13 +8,22 @@
|
||||||
<!-- Ensure the documentation file path is predictable so it can be packed -->
|
<!-- Ensure the documentation file path is predictable so it can be packed -->
|
||||||
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
|
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<!-- Include the generated XML documentation in the produced NuGet package
|
||||||
|
next to the assembly under the lib/<tfm>/ folder. This guarantees the
|
||||||
|
consumers installing the package will receive IntelliSense XML docs. -->
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="$(OutputPath)$(AssemblyName).xml">
|
||||||
|
<Pack>true</Pack>
|
||||||
|
<PackagePath>lib\$(TargetFramework)\</PackagePath>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- NuGet package metadata -->
|
<!-- NuGet package metadata -->
|
||||||
<PackageId>AIFotoONLUS.Core</PackageId>
|
<PackageId>AIFotoONLUS.Core</PackageId>
|
||||||
<Authors>Maddo</Authors>
|
<Authors>Maddo</Authors>
|
||||||
<Company>Maddo</Company>
|
<Company>Maddo</Company>
|
||||||
<Description>Core library for AIFotoONLUS image processing and recognition.</Description>
|
<Description>Core library for AIFotoONLUS image processing and recognition.</Description>
|
||||||
<RepositoryUrl>https://forgejo.maddoscientisto.net/maddo/AIFotoONLUS</RepositoryUrl>
|
<RepositoryUrl>https://gitlab.com/MaddoScientisto/aifotoonlus</RepositoryUrl>
|
||||||
<!-- Versioning: use MinVer to infer semantic versions from Git tags. When no tag is present,
|
<!-- Versioning: use MinVer to infer semantic versions from Git tags. When no tag is present,
|
||||||
projects will fall back to the default below. -->
|
projects will fall back to the default below. -->
|
||||||
<Version>0.1.0</Version>
|
<Version>0.1.0</Version>
|
||||||
|
|
|
||||||
|
|
@ -139,12 +139,6 @@
|
||||||
must match the class ordering used by the trained recognition network.
|
must match the class ordering used by the trained recognition network.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:AIFotoONLUS.Core.ModelConfiguration.UseGpu">
|
|
||||||
<summary>
|
|
||||||
When enabled, request OpenCV DNN CUDA backend/target for inference.
|
|
||||||
The installed OpenCV runtime must have CUDA support or model loading/forwarding may fail.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:AIFotoONLUS.Core.ModelConfiguration.EnableCropSaving">
|
<member name="P:AIFotoONLUS.Core.ModelConfiguration.EnableCropSaving">
|
||||||
<summary>
|
<summary>
|
||||||
When enabled, recognition crops will be saved to disk under
|
When enabled, recognition crops will be saved to disk under
|
||||||
|
|
|
||||||
|
|
@ -55,12 +55,6 @@ namespace AIFotoONLUS.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] NumberClasses { get; set; } = new[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
public string[] NumberClasses { get; set; } = new[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// When enabled, request OpenCV DNN CUDA backend/target for inference.
|
|
||||||
/// The installed OpenCV runtime must have CUDA support or model loading/forwarding may fail.
|
|
||||||
/// </summary>
|
|
||||||
public bool UseGpu { get; set; } = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When enabled, recognition crops will be saved to disk under
|
/// When enabled, recognition crops will be saved to disk under
|
||||||
/// "logs/crops" for diagnostic inspection. Disabled by default.
|
/// "logs/crops" for diagnostic inspection. Disabled by default.
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,10 @@ namespace AIFotoONLUS.Core
|
||||||
_detectionNet = CvDnn.ReadNetFromDarknet(_cfg.DetectionCfg, _cfg.DetectionWeights);
|
_detectionNet = CvDnn.ReadNetFromDarknet(_cfg.DetectionCfg, _cfg.DetectionWeights);
|
||||||
_recognitionNet = CvDnn.ReadNetFromDarknet(_cfg.RecognitionCfg, _cfg.RecognitionWeights);
|
_recognitionNet = CvDnn.ReadNetFromDarknet(_cfg.RecognitionCfg, _cfg.RecognitionWeights);
|
||||||
|
|
||||||
ConfigureNetRuntime(_detectionNet, _cfg.UseGpu);
|
_detectionNet.SetPreferableBackend(Backend.OPENCV);
|
||||||
ConfigureNetRuntime(_recognitionNet, _cfg.UseGpu);
|
_detectionNet.SetPreferableTarget(Target.CPU);
|
||||||
|
_recognitionNet.SetPreferableBackend(Backend.OPENCV);
|
||||||
|
_recognitionNet.SetPreferableTarget(Target.CPU);
|
||||||
// Let OpenCV use multiple threads internally (use number of logical processors)
|
// Let OpenCV use multiple threads internally (use number of logical processors)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -106,11 +108,6 @@ namespace AIFotoONLUS.Core
|
||||||
{
|
{
|
||||||
// Ignore if not supported by OpenCvSharp build
|
// Ignore if not supported by OpenCvSharp build
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cfg.UseGpu)
|
|
||||||
{
|
|
||||||
ValidateGpuRuntime();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
@ -122,38 +119,6 @@ namespace AIFotoONLUS.Core
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryValidateGpuRuntime(ModelConfiguration cfg, ILogger? logger, out string? failureMessage)
|
|
||||||
{
|
|
||||||
if (cfg is null) throw new ArgumentNullException(nameof(cfg));
|
|
||||||
|
|
||||||
var probeConfiguration = new ModelConfiguration
|
|
||||||
{
|
|
||||||
DetectionCfg = cfg.DetectionCfg,
|
|
||||||
DetectionWeights = cfg.DetectionWeights,
|
|
||||||
RecognitionCfg = cfg.RecognitionCfg,
|
|
||||||
RecognitionWeights = cfg.RecognitionWeights,
|
|
||||||
ConfidenceThreshold = cfg.ConfidenceThreshold,
|
|
||||||
NmsThreshold = cfg.NmsThreshold,
|
|
||||||
DetectionInputSize = cfg.DetectionInputSize,
|
|
||||||
RecognitionInputSize = cfg.RecognitionInputSize,
|
|
||||||
NumberClasses = cfg.NumberClasses,
|
|
||||||
EnableCropSaving = cfg.EnableCropSaving,
|
|
||||||
UseGpu = true
|
|
||||||
};
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var engine = new NumberRecognitionEngine(probeConfiguration, logger);
|
|
||||||
failureMessage = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
failureMessage = ex.GetBaseException().Message;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string SanitizeFileName(string name)
|
private static string SanitizeFileName(string name)
|
||||||
{
|
{
|
||||||
foreach (var c in Path.GetInvalidFileNameChars()) name = name.Replace(c, '_');
|
foreach (var c in Path.GetInvalidFileNameChars()) name = name.Replace(c, '_');
|
||||||
|
|
@ -162,39 +127,6 @@ namespace AIFotoONLUS.Core
|
||||||
|
|
||||||
private string[] GetOutputLayerNames(Net net) => net.GetUnconnectedOutLayersNames();
|
private string[] GetOutputLayerNames(Net net) => net.GetUnconnectedOutLayersNames();
|
||||||
|
|
||||||
private static void ConfigureNetRuntime(Net net, bool useGpu)
|
|
||||||
{
|
|
||||||
if (useGpu)
|
|
||||||
{
|
|
||||||
net.SetPreferableBackend(Backend.CUDA);
|
|
||||||
net.SetPreferableTarget(Target.CUDA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
net.SetPreferableBackend(Backend.OPENCV);
|
|
||||||
net.SetPreferableTarget(Target.CPU);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ValidateGpuRuntime()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var detectionProbe = new Mat(_cfg.DetectionInputSize.Height, _cfg.DetectionInputSize.Width, MatType.CV_8UC3, Scalar.All(0));
|
|
||||||
_ = DetectTextRegions(_detectionNet, detectionProbe).Take(1).ToArray();
|
|
||||||
|
|
||||||
using var recognitionProbe = new Mat(_cfg.RecognitionInputSize.Height, _cfg.RecognitionInputSize.Width, MatType.CV_8UC3, Scalar.All(0));
|
|
||||||
using var blob = CvDnn.BlobFromImage(recognitionProbe, 0.00392, _cfg.RecognitionInputSize, new Scalar(0, 0, 0), true, false);
|
|
||||||
_recognitionNet.SetInput(blob);
|
|
||||||
using var output = _recognitionNet.Forward();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException(
|
|
||||||
"OpenCV DNN CUDA runtime validation failed. Disable number AI GPU mode or use an OpenCV runtime built with CUDA DNN support.",
|
|
||||||
ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Detect text regions in the supplied image using the detection network.
|
/// Detect text regions in the supplied image using the detection network.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -220,7 +152,7 @@ namespace AIFotoONLUS.Core
|
||||||
var outNames = GetOutputLayerNames(detectionNet);
|
var outNames = GetOutputLayerNames(detectionNet);
|
||||||
var outsList = new List<Mat>();
|
var outsList = new List<Mat>();
|
||||||
detectionNet.Forward(outsList, outNames);
|
detectionNet.Forward(outsList, outNames);
|
||||||
|
|
||||||
Mat[] outs = outsList.ToArray();
|
Mat[] outs = outsList.ToArray();
|
||||||
if (outs.Length == 0)
|
if (outs.Length == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -230,15 +162,15 @@ namespace AIFotoONLUS.Core
|
||||||
var fallback = new List<Mat>();
|
var fallback = new List<Mat>();
|
||||||
for (int on = 0; on < outNames.Length; on++)
|
for (int on = 0; on < outNames.Length; on++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var single = detectionNet.Forward(outNames[on]);
|
var single = detectionNet.Forward(outNames[on]);
|
||||||
fallback.Add(single);
|
fallback.Add(single);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger?.LogError(ex, "Fallback Forward failed for {name}", outNames[on]);
|
_logger?.LogError(ex, "Fallback Forward failed for {name}", outNames[on]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fallback.Count > 0)
|
if (fallback.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -289,21 +221,21 @@ namespace AIFotoONLUS.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxScore > _cfg.ConfidenceThreshold)
|
if (maxScore > _cfg.ConfidenceThreshold)
|
||||||
{
|
{
|
||||||
int x = (int)Math.Max(0, Math.Round(cx - w / 2));
|
int x = (int)Math.Max(0, Math.Round(cx - w / 2));
|
||||||
int y = (int)Math.Max(0, Math.Round(cy - h / 2));
|
int y = (int)Math.Max(0, Math.Round(cy - h / 2));
|
||||||
var rect = new Rect(x, y, (int)Math.Round(w), (int)Math.Round(h));
|
var rect = new Rect(x, y, (int)Math.Round(w), (int)Math.Round(h));
|
||||||
boxes.Add(rect);
|
boxes.Add(rect);
|
||||||
confidences.Add(maxScore);
|
confidences.Add(maxScore);
|
||||||
classIds.Add(bestClass);
|
classIds.Add(bestClass);
|
||||||
centerXList.Add(cx);
|
centerXList.Add(cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boxes.Count == 0) return Enumerable.Empty<DetectedRegion>();
|
if (boxes.Count == 0) return Enumerable.Empty<DetectedRegion>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CvDnn.NMSBoxes(boxes, confidences, (float)_cfg.ConfidenceThreshold, (float)_cfg.NmsThreshold, out int[] indices);
|
CvDnn.NMSBoxes(boxes, confidences, (float)_cfg.ConfidenceThreshold, (float)_cfg.NmsThreshold, out int[] indices);
|
||||||
|
|
||||||
|
|
@ -554,8 +486,10 @@ namespace AIFotoONLUS.Core
|
||||||
{
|
{
|
||||||
var det = CvDnn.ReadNetFromDarknet(_cfg.DetectionCfg, _cfg.DetectionWeights);
|
var det = CvDnn.ReadNetFromDarknet(_cfg.DetectionCfg, _cfg.DetectionWeights);
|
||||||
var rec = CvDnn.ReadNetFromDarknet(_cfg.RecognitionCfg, _cfg.RecognitionWeights);
|
var rec = CvDnn.ReadNetFromDarknet(_cfg.RecognitionCfg, _cfg.RecognitionWeights);
|
||||||
ConfigureNetRuntime(det, _cfg.UseGpu);
|
det.SetPreferableBackend(Backend.OPENCV);
|
||||||
ConfigureNetRuntime(rec, _cfg.UseGpu);
|
det.SetPreferableTarget(Target.CPU);
|
||||||
|
rec.SetPreferableBackend(Backend.OPENCV);
|
||||||
|
rec.SetPreferableTarget(Target.CPU);
|
||||||
netsBag.Add((det, rec));
|
netsBag.Add((det, rec));
|
||||||
return (det, rec);
|
return (det, rec);
|
||||||
});
|
});
|
||||||
|
|
@ -591,7 +525,8 @@ namespace AIFotoONLUS.Core
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var tempRec = CvDnn.ReadNetFromDarknet(_cfg.RecognitionCfg, _cfg.RecognitionWeights);
|
using var tempRec = CvDnn.ReadNetFromDarknet(_cfg.RecognitionCfg, _cfg.RecognitionWeights);
|
||||||
ConfigureNetRuntime(tempRec, _cfg.UseGpu);
|
tempRec.SetPreferableBackend(Backend.OPENCV);
|
||||||
|
tempRec.SetPreferableTarget(Target.CPU);
|
||||||
var alt = RecognizeDigits(crop, tempRec, ctx);
|
var alt = RecognizeDigits(crop, tempRec, ctx);
|
||||||
if (!string.IsNullOrEmpty(alt)) txt = alt;
|
if (!string.IsNullOrEmpty(alt)) txt = alt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue