mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 03:46:59 +08:00
Initial commit: openalpr-net (C++/CLI wrapper) and openalprnet-cli (C#)
This commit is contained in:
40
openalpr-net/AssemblyInfo.cpp
Normal file
40
openalpr-net/AssemblyInfo.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Reflection;
|
||||
using namespace System::Runtime::CompilerServices;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
using namespace System::Security::Permissions;
|
||||
|
||||
//
|
||||
// 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:AssemblyTitleAttribute("openalprnet")];
|
||||
[assembly:AssemblyDescriptionAttribute("")];
|
||||
[assembly:AssemblyConfigurationAttribute("")];
|
||||
[assembly:AssemblyCompanyAttribute("")];
|
||||
[assembly:AssemblyProductAttribute("openalprnet")];
|
||||
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2015")];
|
||||
[assembly:AssemblyTrademarkAttribute("")];
|
||||
[assembly:AssemblyCultureAttribute("")];
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the value or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly:AssemblyVersionAttribute("1.0.*")];
|
||||
|
||||
[assembly:ComVisible(false)];
|
||||
|
||||
[assembly:CLSCompliantAttribute(true)];
|
||||
|
||||
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
|
5
openalpr-net/Stdafx.cpp
Normal file
5
openalpr-net/Stdafx.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// openalpr-net.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
7
openalpr-net/Stdafx.h
Normal file
7
openalpr-net/Stdafx.h
Normal file
@@ -0,0 +1,7 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently,
|
||||
// but are changed infrequently
|
||||
|
||||
#pragma once
|
||||
|
||||
|
BIN
openalpr-net/app.ico
Normal file
BIN
openalpr-net/app.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
openalpr-net/app.rc
Normal file
BIN
openalpr-net/app.rc
Normal file
Binary file not shown.
257
openalpr-net/openalpr-net.cpp
Normal file
257
openalpr-net/openalpr-net.cpp
Normal file
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Dr. Masroor Ehsan
|
||||
*
|
||||
* This file is part of OpenAlpr.Net.
|
||||
*
|
||||
* OpenAlpr.Net is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License
|
||||
* version 3 as published by the Free Software Foundation
|
||||
*
|
||||
* This program 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
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openalpr-net.h"
|
||||
#include "alpr.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#using <mscorlib.dll>
|
||||
//#include <msclr\marshal.h>
|
||||
#include <msclr\marshal_cppstd.h>
|
||||
|
||||
using namespace System;
|
||||
using namespace msclr::interop;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
|
||||
namespace openalprnet {
|
||||
|
||||
ref class StringConverter
|
||||
{
|
||||
public:
|
||||
static std::vector<unsigned char> ToVector(array<unsigned char>^ src)
|
||||
{
|
||||
std::vector<unsigned char> result(src->Length);
|
||||
pin_ptr<unsigned char> pin(&src[0]);
|
||||
unsigned char *first(pin), *last(pin + src->Length);
|
||||
std::copy(first, last, result.begin());
|
||||
return result;
|
||||
}
|
||||
|
||||
static System::String^ ToManagedString(std::string s)
|
||||
{
|
||||
return gcnew String(s.c_str());
|
||||
}
|
||||
|
||||
static std::string ToStlString(System::String^ s)
|
||||
{
|
||||
IntPtr ptr = Marshal::StringToHGlobalAnsi(s);
|
||||
if(ptr != IntPtr::Zero)
|
||||
{
|
||||
std::string tmp(reinterpret_cast<char*>(static_cast<void*>(ptr)));
|
||||
Marshal::FreeHGlobal(ptr);
|
||||
return tmp;
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
};
|
||||
|
||||
public ref class AlprPlateNet
|
||||
{
|
||||
public:
|
||||
AlprPlateNet(AlprPlate plate){
|
||||
//_characters = marshal_as<System::String^>(plate.characters);
|
||||
m_characters = StringConverter::ToManagedString(plate.characters);
|
||||
m_overall_confidence=plate.overall_confidence;
|
||||
m_matches_template=plate.matches_template;
|
||||
}
|
||||
|
||||
property System::String^ characters {
|
||||
System::String^ get() {
|
||||
return m_characters;
|
||||
}
|
||||
}
|
||||
|
||||
property float overall_confidence {
|
||||
float get() {
|
||||
return m_overall_confidence;
|
||||
}
|
||||
}
|
||||
|
||||
property bool matches_template {
|
||||
bool get() {
|
||||
return m_matches_template;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
System::String^ m_characters;
|
||||
float m_overall_confidence;
|
||||
bool m_matches_template;
|
||||
};
|
||||
|
||||
public ref class AlprResultNet
|
||||
{
|
||||
public:
|
||||
AlprResultNet() : m_Impl( new AlprResult ) {}
|
||||
|
||||
AlprResultNet(AlprResult* result) : m_Impl( result ) {}
|
||||
|
||||
property int requested_topn {
|
||||
int get() {
|
||||
return m_Impl->requested_topn;
|
||||
}
|
||||
}
|
||||
|
||||
property int regionConfidence {
|
||||
int get() {
|
||||
return m_Impl->regionConfidence;
|
||||
}
|
||||
}
|
||||
|
||||
property System::String^ region {
|
||||
System::String^ get() {
|
||||
return StringConverter::ToManagedString(m_Impl->region);
|
||||
}
|
||||
}
|
||||
|
||||
property int result_count {
|
||||
int get() {
|
||||
return m_Impl->result_count;
|
||||
}
|
||||
}
|
||||
|
||||
property AlprPlateNet^ bestPlate {
|
||||
AlprPlateNet^ get() {
|
||||
AlprPlateNet^ result = gcnew AlprPlateNet(m_Impl->bestPlate);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
property List<AlprPlateNet^>^ topNPlates {
|
||||
List<AlprPlateNet^>^ get() {
|
||||
List<AlprPlateNet^>^ list = gcnew List<AlprPlateNet^>(m_Impl->topNPlates.size());
|
||||
for (std::vector<AlprPlate>::iterator itr = m_Impl->topNPlates.begin(); itr != m_Impl->topNPlates.end(); itr++)
|
||||
{
|
||||
list->Add(gcnew AlprPlateNet(*itr));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
property float processing_time_ms {
|
||||
float get() {
|
||||
return m_Impl->processing_time_ms;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
AlprCoordinate plate_points[4];
|
||||
*/
|
||||
private:
|
||||
AlprResult * m_Impl;
|
||||
};
|
||||
|
||||
public ref class AlprNet {
|
||||
public:
|
||||
// Allocate the native object on the C++ Heap via a constructor
|
||||
AlprNet(System::String^ country, System::String^ configFile) : m_Impl( new Alpr(marshal_as<std::string>(country), marshal_as<std::string>(configFile)) ) { }
|
||||
|
||||
// Deallocate the native object on a destructor
|
||||
~AlprNet(){
|
||||
delete m_Impl;
|
||||
}
|
||||
|
||||
property int TopN {
|
||||
int get() {
|
||||
return m_topN;
|
||||
}
|
||||
void set( int topn ){
|
||||
m_topN = topn;
|
||||
m_Impl->setTopN(topn);
|
||||
}
|
||||
}
|
||||
|
||||
property bool DetectRegion {
|
||||
bool get() {
|
||||
return m_detectRegion;
|
||||
}
|
||||
void set( bool detectRegion ) {
|
||||
m_detectRegion = detectRegion;
|
||||
m_Impl->setDetectRegion(detectRegion);
|
||||
}
|
||||
}
|
||||
|
||||
property System::String^ DefaultRegion {
|
||||
System::String^ get() {
|
||||
return m_defaultRegion;
|
||||
}
|
||||
void set( System::String^ region ){
|
||||
m_defaultRegion = region;
|
||||
m_Impl->setDefaultRegion(marshal_as<std::string>(region));
|
||||
}
|
||||
}
|
||||
|
||||
//std::vector<AlprResult> recognize(std::string filepath);
|
||||
//std::vector<AlprResult> recognize(std::string filepath, std::vector<AlprRegionOfInterest> regionsOfInterest);
|
||||
//std::vector<AlprResult> recognize(std::vector<unsigned char> imageBuffer);
|
||||
//std::vector<AlprResult> recognize(std::vector<unsigned char> imageBuffer, std::vector<AlprRegionOfInterest> regionsOfInterest);
|
||||
List<AlprResultNet^>^ recognize(System::String^ filepath) {
|
||||
m_results = new std::vector<AlprResult>(m_Impl->recognize(marshal_as<std::string>(filepath)));
|
||||
std::vector<AlprResult>& runList = *m_results;
|
||||
std::vector<AlprResult>::iterator itr;
|
||||
List<AlprResultNet^>^ list = gcnew List<AlprResultNet^>(runList.size());
|
||||
for (itr = runList.begin(); itr != runList.end(); itr++)
|
||||
{
|
||||
list->Add(gcnew AlprResultNet(&*itr));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
List<AlprResultNet^>^ recognize(cli::array<unsigned char>^ imageBuffer) {
|
||||
std::vector<unsigned char> p = StringConverter::ToVector(imageBuffer);
|
||||
m_results = new std::vector<AlprResult>(m_Impl->recognize(p));
|
||||
std::vector<AlprResult>& runList = *m_results;
|
||||
std::vector<AlprResult>::iterator itr;
|
||||
List<AlprResultNet^>^ list = gcnew List<AlprResultNet^>(runList.size());
|
||||
for (itr = runList.begin(); itr != runList.end(); itr++)
|
||||
{
|
||||
list->Add(gcnew AlprResultNet(&*itr));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
bool isLoaded() {
|
||||
return m_Impl->isLoaded();
|
||||
}
|
||||
|
||||
static System::String^ getVersion() {
|
||||
return StringConverter::ToManagedString(Alpr::getVersion());
|
||||
}
|
||||
|
||||
System::String^ toJson() {
|
||||
std::string json = m_Impl->toJson(*m_results, -1);
|
||||
return StringConverter::ToManagedString(json);
|
||||
}
|
||||
|
||||
protected:
|
||||
// Deallocate the native object on the finalizer just in case no destructor is called
|
||||
!AlprNet() {
|
||||
delete m_Impl;
|
||||
}
|
||||
|
||||
private:
|
||||
Alpr * m_Impl;
|
||||
std::vector<AlprResult>* m_results;
|
||||
int m_topN;
|
||||
bool m_detectRegion;
|
||||
System::String^ m_defaultRegion;
|
||||
};
|
||||
}
|
9
openalpr-net/openalpr-net.h
Normal file
9
openalpr-net/openalpr-net.h
Normal file
@@ -0,0 +1,9 @@
|
||||
// openalpr-net.h
|
||||
|
||||
#pragma once
|
||||
|
||||
//using namespace System;
|
||||
|
||||
namespace openalprnet {
|
||||
|
||||
}
|
101
openalpr-net/openalpr-net.vcxproj
Normal file
101
openalpr-net/openalpr-net.vcxproj
Normal file
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{4044340C-C435-4A1F-8F12-0806C38AE3B6}</ProjectGuid>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<RootNamespace>openalprnet</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<AdditionalIncludeDirectories>C:\projects\openalpr\libraries\tesseract-ocr\api;C:\projects\openalpr\libraries\tesseract-ocr\ccstruct;C:\projects\openalpr\libraries\tesseract-ocr\ccmain;C:\projects\openalpr\libraries\tesseract-ocr\ccutil;C:\projects\openalpr\libraries\opencv;C:\projects\openalpr\libraries\opencv\include;C:\projects\openalpr\libraries\opencv\include\opencv;C:\projects\openalpr\libraries\opencv\modules\core\include;C:\projects\openalpr\libraries\opencv\modules\flann\include;C:\projects\openalpr\libraries\opencv\modules\imgproc\include;C:\projects\openalpr\libraries\opencv\modules\highgui\include;C:\projects\openalpr\libraries\opencv\modules\features2d\include;C:\projects\openalpr\libraries\opencv\modules\calib3d\include;C:\projects\openalpr\libraries\opencv\modules\ml\include;C:\projects\openalpr\libraries\opencv\modules\video\include;C:\projects\openalpr\libraries\opencv\modules\legacy\include;C:\projects\openalpr\libraries\opencv\modules\objdetect\include;C:\projects\openalpr\libraries\opencv\modules\photo\include;C:\projects\openalpr\libraries\opencv\modules\gpu\include;C:\projects\openalpr\libraries\opencv\modules\ocl\include;C:\projects\openalpr\libraries\opencv\modules\nonfree\include;C:\projects\openalpr\libraries\opencv\modules\contrib\include;C:\projects\openalpr\libraries\opencv\modules\stitching\include;C:\projects\openalpr\libraries\opencv\modules\superres\include;C:\projects\openalpr\libraries\opencv\modules\ts\include;C:\projects\openalpr\libraries\opencv\modules\videostab\include;C:\projects\openalpr\src\openalpr;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_videostab248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_ts248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_superres248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_stitching248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_contrib248.lib;C:\projects\openalpr\libraries\tesseract-ocr\vs2010\LIB_Release\libtesseract303-static.lib;C:\projects\openalpr\libraries\tesseract-ocr\vs2010\LIB_Release\liblept170.lib;ws2_32.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_nonfree248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_ocl248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_gpu248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_photo248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_objdetect248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_legacy248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_video248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_ml248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_calib3d248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_features2d248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_highgui248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_imgproc248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_flann248.lib;C:\projects\openalpr\libraries\opencv\lib\Release\opencv_core248.lib;C:\projects\openalpr\src\openalpr\support\Release\support.lib;C:\projects\openalpr\src\openalpr\Release\openalpr-static.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="openalpr-net.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="Stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AssemblyInfo.cpp" />
|
||||
<ClCompile Include="openalpr-net.cpp" />
|
||||
<ClCompile Include="Stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="app.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
49
openalpr-net/openalpr-net.vcxproj.filters
Normal file
49
openalpr-net/openalpr-net.vcxproj.filters
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="openalpr-net.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="openalpr-net.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AssemblyInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="app.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
3
openalpr-net/openalpr-net.vcxproj.user
Normal file
3
openalpr-net/openalpr-net.vcxproj.user
Normal file
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
3
openalpr-net/resource.h
Normal file
3
openalpr-net/resource.h
Normal file
@@ -0,0 +1,3 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by app.rc
|
58
openalprnet-cli/Program.cs
Normal file
58
openalprnet-cli/Program.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Dr. Masroor Ehsan
|
||||
*
|
||||
* This file is part of OpenAlpr.Net.
|
||||
*
|
||||
* OpenAlpr.Net is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License
|
||||
* version 3 as published by the Free Software Foundation
|
||||
*
|
||||
* This program 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
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using openalprnet;
|
||||
|
||||
namespace openalprnet_cli
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
public static string AssemblyDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
var codeBase = Assembly.GetExecutingAssembly().CodeBase;
|
||||
var uri = new UriBuilder(codeBase);
|
||||
var path = Uri.UnescapeDataString(uri.Path);
|
||||
return Path.GetDirectoryName(path);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(AlprNet.getVersion());
|
||||
var config = Path.Combine(AssemblyDirectory, "openalpr.conf");
|
||||
var alpr = new AlprNet("us", config);
|
||||
var loaded = alpr.isLoaded();
|
||||
var samplePath = Path.Combine(AssemblyDirectory, @"samples\us-1.jpg");
|
||||
var imgBytes = File.ReadAllBytes(samplePath);
|
||||
//alpr.TopN = 3;
|
||||
alpr.DefaultRegion = "us";
|
||||
alpr.DetectRegion = true;
|
||||
//var results = alpr.recognize(samplePath);
|
||||
var results = alpr.recognize(imgBytes);
|
||||
var json = alpr.toJson();
|
||||
Console.WriteLine(json);
|
||||
var plates = results.First().topNPlates;
|
||||
}
|
||||
}
|
||||
}
|
36
openalprnet-cli/Properties/AssemblyInfo.cs
Normal file
36
openalprnet-cli/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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: AssemblyTitle("openalprnet-cli")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("openalprnet-cli")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 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("42477de2-b13e-4959-a03e-ae43c65e68f3")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
openalprnet-cli/openalprnet-cli.csproj
Normal file
63
openalprnet-cli/openalprnet-cli.csproj
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{BD50C6C1-EEB9-48D2-A87C-70F5342579DD}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>openalprnet_cli</RootNamespace>
|
||||
<AssemblyName>openalprnet-cli</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\openalpr-net\openalpr-net.vcxproj">
|
||||
<Project>{4044340C-C435-4A1F-8F12-0806C38AE3B6}</Project>
|
||||
<Name>openalpr-net</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Reference in New Issue
Block a user