aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TCC/Tango.TCC.Service
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/TCC/Tango.TCC.Service')
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs27
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs48
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj6
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config43
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config1
5 files changed, 117 insertions, 8 deletions
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs
index ade4f72f3..b3a4d4808 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs
@@ -15,25 +15,44 @@ namespace Tango.TCC.Service.Controllers
public class ColorDetectionController : TangoController
{
[HttpPost]
+ public LoginResponse Login(LoginRequest request)
+ {
+ return new LoginResponse();
+ }
+
+ [HttpPost]
+ public DefinitionResponse GetDefinition(DefinitionRequest request)
+ {
+ return new DefinitionResponse()
+ {
+ TemplateString = TCCServiceConfig.TEMPLATE_STRING,
+ SampleWidth = TCCServiceConfig.SAMPLE_WIDTH,
+ SampleHeight = TCCServiceConfig.SAMPLE_HEIGHT,
+ CameraWidth = TCCServiceConfig.CAMERA_WIDTH,
+ CameraHeight = TCCServiceConfig.CAMERA_HEIGHT,
+ HistogramMethod = TCCServiceConfig.HISTOGRAM_METHOD,
+ SimilarityTolerance = TCCServiceConfig.SIMILARITY_TOLERANCE,
+ EnableDoubleChecking = TCCServiceConfig.ENABLE_DOUBLE_CHECKING,
+ };
+ }
+
+ [HttpPost]
public ColorDetectionResponse Detect(ColorDetectionRequest request)
{
- byte[] bitmapBytes = System.Convert.FromBase64String(request.BitmapString);
+ byte[] bitmapBytes = Convert.FromBase64String(request.BitmapString);
using (ColorDetector detector = new ColorDetector())
{
var output = detector.Detect(new DetectionInput()
{
- Number = request.Number,
Bitmap = ByteString.CopyFrom(bitmapBytes),
Columns = TCCServiceConfig.CARD_COLUMNS,
Rows = TCCServiceConfig.CARD_ROWS,
TargetIndex = TCCServiceConfig.CARD_TARGET_INDEX,
- DebugMode = true,
});
return new ColorDetectionResponse()
{
- Number = (int)output.Number,
ProcessedColor = output.ProcessedColor,
RawColor = output.RawColor,
};
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs
index 8cacbe636..8bedaefe9 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs
@@ -3,12 +3,15 @@ using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
+using Tango.TCC.BL;
using Tango.Web;
namespace Tango.TCC.Service
{
public class TCCServiceConfig : WebConfig
{
+ public static String JWT_TOKEN_SECRET => ConfigurationManager.AppSettings[nameof(JWT_TOKEN_SECRET)].ToString();
+
/// <summary>
/// Gets the number of card columns.
/// </summary>
@@ -23,5 +26,50 @@ namespace Tango.TCC.Service
/// Gets the card target index (hole).
/// </summary>
public static int CARD_TARGET_INDEX => int.Parse(ConfigurationManager.AppSettings[nameof(CARD_TARGET_INDEX)].ToString());
+
+ /// <summary>
+ /// Gets the template image base64 string.
+ /// </summary>
+ public static String TEMPLATE_STRING => ConfigurationManager.AppSettings[nameof(TEMPLATE_STRING)].ToString();
+
+ /// <summary>
+ /// Gets the desired width of the sample image.
+ /// </summary>
+ public static int SAMPLE_WIDTH => int.Parse(ConfigurationManager.AppSettings[nameof(SAMPLE_WIDTH)].ToString());
+
+ /// <summary>
+ /// Gets the desired height of the sample image.
+ /// </summary>
+ public static int SAMPLE_HEIGHT => int.Parse(ConfigurationManager.AppSettings[nameof(SAMPLE_HEIGHT)].ToString());
+
+ /// <summary>
+ /// Gets the recommended camera resolution width.
+ /// </summary>
+ public static int CAMERA_WIDTH => int.Parse(ConfigurationManager.AppSettings[nameof(CAMERA_WIDTH)].ToString());
+
+ /// <summary>
+ /// Gets the recommended camera resolution height.
+ /// </summary>
+ public static int CAMERA_HEIGHT => int.Parse(ConfigurationManager.AppSettings[nameof(CAMERA_HEIGHT)].ToString());
+
+ /// <summary>
+ /// Gets the histogram similarity tolerance.
+ /// </summary>
+ public static double SIMILARITY_TOLERANCE => int.Parse(ConfigurationManager.AppSettings[nameof(SIMILARITY_TOLERANCE)].ToString());
+
+ /// <summary>
+ /// Gets the histogram comparison method.
+ /// </summary>
+ public static CardDetectionHistogramMethods HISTOGRAM_METHOD => (CardDetectionHistogramMethods)Enum.Parse(typeof(CardDetectionHistogramMethods), ConfigurationManager.AppSettings[nameof(HISTOGRAM_METHOD)].ToString());
+
+ /// <summary>
+ /// Gets a value indicating whether to perform a double check of the card arucos.
+ /// </summary>
+ public static bool ENABLE_DOUBLE_CHECKING => bool.Parse(ConfigurationManager.AppSettings[nameof(ENABLE_DOUBLE_CHECKING)].ToString());
+
+ /// <summary>
+ /// Gets the mobile application ID.
+ /// </summary>
+ public static String APP_ID => ConfigurationManager.AppSettings[nameof(APP_ID)].ToString();
}
} \ No newline at end of file
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj b/Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj
index 43a493f8e..78e13e6d4 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj
@@ -46,6 +46,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+ </Reference>
<Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config b/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config
index 754e88280..d2433dc9b 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config
@@ -4,15 +4,43 @@
https://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
+ <configSections>
+ <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
+
+ <add key="DB_ADDRESS" value="twine.database.windows.net" />
+ <add key="DB_USER_NAME" value="Roy" />
+ <add key="DB_PASSWORD" value="Aa123456" />
+ <add key="DB_CATALOG" value="TCC_DEV" />
+ <add key="STORAGE_ACCOUNT" value="DefaultEndpointsProtocol=https;AccountName=tangostorage;AccountKey=S4z/D+Yg6mwMis+bs/VpcDLA9yE1iZaYq23shQlRIi2KmM9E7JY8zdZjeAPOPdG3gONHoNDEpsgH6D4cqQ/bsA==;EndpointSuffix=core.windows.net" />
+ <add key="TENANT_ID" value="2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4" />
+ <add key="CLIENT_ID" value="ec612854-7abc-457b-808a-5d0c5ba80c57" />
+ <add key="APP_SECRET" value="54)019A7wv+#86l*PQcQWYKu%fd4Dv!@G=VhCiDI5rD+H4BTH" />
+ <add key="DEPLOYMENT_SLOT" value="DEV" />
+ <add key="ENVIRONMENT_GROUP" value="Tango DEV" />
+ <add key="JWT_TOKEN_SECRET" value="GQDstcKsx0NHjLOuXOYg5MbeJ1yT0u1iwDVTwine" />
+
<add key="CARD_COLUMNS" value="10" />
<add key="CARD_ROWS" value="11" />
<add key="CARD_TARGET_INDEX" value="99" />
+ <add key="TEMPLATE_STRING" value="PUT TEMPLATE STRING HERE!" />
+ <add key="SAMPLE_WIDTH" value="300" />
+ <add key="SAMPLE_HEIGHT" value="330" />
+ <add key="CAMERA_WIDTH" value="1280" />
+ <add key="CAMERA_HEIGHT" value="720" />
+ <add key="SIMILARITY_TOLERANCE" value="50" />
+ <add key="HISTOGRAM_METHOD" value="Chi_Square" />
+ <add key="ENABLE_DOUBLE_CHECKING" value="True" />
+ <add key="APP_ID" value="Tdf793i4ughsiduf8749509237885ehgfdlkghlT" />
+
+
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
@@ -34,12 +62,13 @@
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
- <handlers>
+ <handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
- </handlers></system.webServer>
+ </handlers>
+ </system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
@@ -49,7 +78,7 @@
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.1" newVersion="4.0.2.1" />
- </dependentAssembly>
+ </dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
@@ -102,4 +131,10 @@
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
-</configuration>
+ <entityFramework>
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+ <providers>
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+ </providers>
+ </entityFramework>
+</configuration> \ No newline at end of file
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config b/Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config
index 34d59e98c..115c40d26 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config
@@ -2,6 +2,7 @@
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net461" />
<package id="bootstrap" version="3.3.7" targetFramework="net461" />
+ <package id="EntityFramework" version="6.2.0" targetFramework="net461" />
<package id="Google.Protobuf" version="3.4.1" targetFramework="net461" />
<package id="jQuery" version="3.3.1" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights" version="2.5.1" targetFramework="net461" />