507 lines
19 KiB
HTML
507 lines
19 KiB
HTML
|
|
<!DOCTYPE html>
|
|
|
|
<html class="no-js" lang="en">
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<meta content="width=device-width,initial-scale=1" name="viewport"/>
|
|
<meta content="Rohmer Maxime" name="author"/>
|
|
<link href="../../assets/images/favicon.png" rel="icon"/>
|
|
<meta content="mkdocs-1.4.3, mkdocs-material-8.5.0" name="generator"/>
|
|
<title>Zone.cs - Documentation Track Trends</title>
|
|
<link href="../../assets/stylesheets/main.2e8b5541.min.css" rel="stylesheet"/>
|
|
<link href="../../assets/stylesheets/palette.cbb835fc.min.css" rel="stylesheet"/>
|
|
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
|
|
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback" rel="stylesheet"/>
|
|
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
|
|
<script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
|
|
<link href="../../assets/stylesheets/glightbox.min.css" rel="stylesheet"/><style>html.glightbox-open { overflow: initial; height: 100%; }</style><script src="../../assets/javascripts/glightbox.min.js"></script></head>
|
|
<body data-md-color-accent="" data-md-color-primary="" data-md-color-scheme="default" dir="ltr">
|
|
<script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
|
|
<input autocomplete="off" class="md-toggle" data-md-toggle="drawer" id="__drawer" type="checkbox"/>
|
|
<input autocomplete="off" class="md-toggle" data-md-toggle="search" id="__search" type="checkbox"/>
|
|
<label class="md-overlay" for="__drawer"></label>
|
|
<div data-md-component="skip">
|
|
<a class="md-skip" href="#zonecs">
|
|
Skip to content
|
|
</a>
|
|
</div>
|
|
<div data-md-component="announce">
|
|
</div>
|
|
<header class="md-header" data-md-component="header">
|
|
<nav aria-label="Header" class="md-header__inner md-grid">
|
|
<a aria-label="Documentation Track Trends" class="md-header__button md-logo" data-md-component="logo" href="../.." title="Documentation Track Trends">
|
|
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"></path></svg>
|
|
</a>
|
|
<label class="md-header__button md-icon" for="__drawer">
|
|
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"></path></svg>
|
|
</label>
|
|
<div class="md-header__title" data-md-component="header-title">
|
|
<div class="md-header__ellipsis">
|
|
<div class="md-header__topic">
|
|
<span class="md-ellipsis">
|
|
Documentation Track Trends
|
|
</span>
|
|
</div>
|
|
<div class="md-header__topic" data-md-component="header-topic">
|
|
<span class="md-ellipsis">
|
|
|
|
Zone.cs
|
|
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<form class="md-header__option" data-md-component="palette">
|
|
<input aria-hidden="true" class="md-option" data-md-color-accent="" data-md-color-media="(prefers-color-scheme: light)" data-md-color-primary="" data-md-color-scheme="default" id="__palette_1" name="__palette" type="radio"/>
|
|
<input aria-hidden="true" class="md-option" data-md-color-accent="" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-primary="" data-md-color-scheme="slate" id="__palette_2" name="__palette" type="radio"/>
|
|
</form>
|
|
</nav>
|
|
</header>
|
|
<div class="md-container" data-md-component="container">
|
|
<main class="md-main" data-md-component="main">
|
|
<div class="md-main__inner md-grid">
|
|
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation">
|
|
<div class="md-sidebar__scrollwrap">
|
|
<div class="md-sidebar__inner">
|
|
<nav aria-label="Navigation" class="md-nav md-nav--primary" data-md-level="0">
|
|
<label class="md-nav__title" for="__drawer">
|
|
<a aria-label="Documentation Track Trends" class="md-nav__button md-logo" data-md-component="logo" href="../.." title="Documentation Track Trends">
|
|
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"></path></svg>
|
|
</a>
|
|
Documentation Track Trends
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix="">
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../..">
|
|
Rapport Track Trends V1.0
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../../CahierDesCharges/">
|
|
Cahier des charges
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../../jdb/">
|
|
Journal de bord
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
|
|
<input checked="" class="md-nav__toggle md-toggle" data-md-toggle="__nav_4" id="__nav_4" type="checkbox"/>
|
|
<label class="md-nav__link" for="__nav_4">
|
|
Code
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
<nav aria-label="Code" class="md-nav" data-md-level="1">
|
|
<label class="md-nav__title" for="__nav_4">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Code
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix="">
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../ConfigurationTool/">
|
|
ConfigurationTool.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../DriverGapToLeaderWindow/">
|
|
DriverGapToLeaderWindow.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../DriverPositionWindow/">
|
|
DriverPositionWindow.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../F1TVEmulator/">
|
|
F1TVEmulator.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../Program/">
|
|
Program.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../Window/">
|
|
Window.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../DriverData/">
|
|
DriverData.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../DriverLapTimeWindow/">
|
|
DriverLapTimeWindow.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../DriverSectorWindow/">
|
|
DriverSectorWindow.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../Form1/">
|
|
Form1.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../Reader/">
|
|
Reader.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item md-nav__item--active">
|
|
<input class="md-nav__toggle md-toggle" data-md-toggle="toc" id="__toc" type="checkbox"/>
|
|
<a class="md-nav__link md-nav__link--active" href="./">
|
|
Zone.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../DriverDrsWindow/">
|
|
DriverDrsWindow.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../DriverNameWindow/">
|
|
DriverNameWindow.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../DriverTyresWindow/">
|
|
DriverTyresWindow.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../OcrImage/">
|
|
OcrImage.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../Settings/">
|
|
Settings.cs
|
|
</a>
|
|
</li>
|
|
<li class="md-nav__item">
|
|
<a class="md-nav__link" href="../recoverCookiesCSV/">
|
|
recoverCookiesCSV.py
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc">
|
|
<div class="md-sidebar__scrollwrap">
|
|
<div class="md-sidebar__inner">
|
|
<nav aria-label="Table of contents" class="md-nav md-nav--secondary">
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="md-content" data-md-component="content">
|
|
<article class="md-content__inner md-typeset">
|
|
<h1 id="zonecs">Zone.cs</h1>
|
|
<pre><code class="language-cs">/// Author : Maxime Rohmer
|
|
/// Date : 08/05/2023
|
|
/// File : Zone.cs
|
|
/// Brief : Class that contains all the methods and infos for a zone. This is designed to be potentially be inherited.
|
|
/// Version : 0.1
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Test_Merge
|
|
{
|
|
public class Zone
|
|
{
|
|
private Rectangle _bounds;
|
|
private List<Zone> _zones;
|
|
private List<Window> _windows;
|
|
private Bitmap _image;
|
|
private string _name;
|
|
|
|
public Bitmap ZoneImage
|
|
{
|
|
get
|
|
{
|
|
//This little trickery lets you have the image that the zone sees
|
|
Bitmap sample = new Bitmap(Bounds.Width, Bounds.Height);
|
|
Graphics g = Graphics.FromImage(sample);
|
|
g.DrawImage(Image, new Rectangle(0, 0, sample.Width, sample.Height), Bounds, GraphicsUnit.Pixel);
|
|
return sample;
|
|
}
|
|
}
|
|
public Bitmap Image
|
|
{
|
|
get { return _image; }
|
|
set
|
|
{
|
|
//It automatically sets the image for the contained windows and zones
|
|
_image = Image;
|
|
foreach (Window w in Windows)
|
|
{
|
|
w.Image = ZoneImage;
|
|
}
|
|
foreach (Zone z in Zones)
|
|
{
|
|
z.Image = Image;
|
|
}
|
|
}
|
|
}
|
|
|
|
public Rectangle Bounds { get => _bounds; protected set => _bounds = value; }
|
|
public List<Zone> Zones { get => _zones; protected set => _zones = value; }
|
|
public List<Window> Windows { get => _windows; protected set => _windows = value; }
|
|
public string Name { get => _name; protected set => _name = value; }
|
|
|
|
public Zone(Bitmap image, Rectangle bounds, string name)
|
|
{
|
|
Windows = new List<Window>();
|
|
Zones = new List<Zone>();
|
|
Name = name;
|
|
|
|
//You cant set the image in the CTOR because the processing is impossible at first initiation
|
|
_image = image;
|
|
Bounds = bounds;
|
|
}
|
|
/// <summary>
|
|
/// Adds a zone to the list of zones
|
|
/// </summary>
|
|
/// <param name="zone">The zone you want to add</param>
|
|
public virtual void AddZone(Zone zone)
|
|
{
|
|
Zones.Add(zone);
|
|
}
|
|
/// <summary>
|
|
/// Add a window to the list of windows
|
|
/// </summary>
|
|
/// <param name="window">the window you want to add</param>
|
|
public virtual void AddWindow(Window window)
|
|
{
|
|
Windows.Add(window);
|
|
}
|
|
/// <summary>
|
|
/// Calls all the windows to do OCR and to give back the results so we can send them to the model
|
|
/// </summary>
|
|
/// <param name="driverList">A list of all the driver in the race to help with text recognition</param>
|
|
/// <returns>A driver data object that contains all the infos about a driver</returns>
|
|
public virtual async Task<DriverData> Decode(List<string> driverList)
|
|
{
|
|
int sectorCount = 0;
|
|
DriverData result = new DriverData();
|
|
Parallel.ForEach(Windows, async w =>
|
|
{
|
|
// A switch would be prettier but I dont think its supported in this C# version
|
|
if (w is DriverNameWindow)
|
|
result.Name = (string)await (w as DriverNameWindow).DecodePng(driverList);
|
|
if (w is DriverDrsWindow)
|
|
result.DRS = (bool)await (w as DriverDrsWindow).DecodePng();
|
|
if (w is DriverGapToLeaderWindow)
|
|
result.GapToLeader = (int)await (w as DriverGapToLeaderWindow).DecodePng();
|
|
if (w is DriverLapTimeWindow)
|
|
result.LapTime = (int)await (w as DriverLapTimeWindow).DecodePng();
|
|
if (w is DriverPositionWindow)
|
|
result.Position = (int)await (w as DriverPositionWindow).DecodePng();
|
|
if (w is DriverSectorWindow)
|
|
{
|
|
sectorCount++;
|
|
if (sectorCount == 1)
|
|
result.Sector1 = (int)await (w as DriverSectorWindow).DecodePng();
|
|
if (sectorCount == 2)
|
|
result.Sector2 = (int)await (w as DriverSectorWindow).DecodePng();
|
|
if (sectorCount == 3)
|
|
result.Sector3 = (int)await (w as DriverSectorWindow).DecodePng();
|
|
}
|
|
if (w is DriverTyresWindow)
|
|
result.CurrentTyre = (Tyre)await (w as DriverTyresWindow).DecodePng();
|
|
});
|
|
return result;
|
|
}
|
|
public virtual Bitmap Draw()
|
|
{
|
|
Bitmap img;
|
|
|
|
//If its the main zone we want to see everything
|
|
if (Zones.Count > 0)
|
|
{
|
|
img = Image;
|
|
}
|
|
else
|
|
{
|
|
img = ZoneImage;
|
|
}
|
|
|
|
Graphics g = Graphics.FromImage(img);
|
|
|
|
//If its the main zone we need to visualize the Zone bounds displayed
|
|
if (Zones.Count > 0)
|
|
g.DrawRectangle(new Pen(Brushes.Violet, 5), Bounds);
|
|
|
|
foreach (Zone z in Zones)
|
|
{
|
|
Rectangle newBounds = new Rectangle(z.Bounds.X, z.Bounds.Y + Bounds.Y, z.Bounds.Width, z.Bounds.Height);
|
|
g.DrawRectangle(Pens.Red, newBounds);
|
|
}
|
|
foreach (Window w in Windows)
|
|
{
|
|
g.DrawRectangle(Pens.Blue, w.Bounds);
|
|
}
|
|
return img;
|
|
}
|
|
public void ResetZones()
|
|
{
|
|
Zones.Clear();
|
|
}
|
|
public void ResetWindows()
|
|
{
|
|
foreach (Zone z in Zones)
|
|
{
|
|
z.ResetWindows();
|
|
}
|
|
Windows.Clear();
|
|
}
|
|
public virtual string ToJSON()
|
|
{
|
|
string result = "";
|
|
result += "\"" + Name + "\":{" + Environment.NewLine;
|
|
result += "\t" + "\"x\":" + Bounds.X + "," + Environment.NewLine;
|
|
result += "\t" + "\"y\":" + Bounds.Y + "," + Environment.NewLine;
|
|
result += "\t" + "\"width\":" + Bounds.Width + "," + Environment.NewLine;
|
|
result += "\t" + "\"height\":" + Bounds.Height;
|
|
|
|
if (Windows.Count != 0)
|
|
{
|
|
result += "," + Environment.NewLine;
|
|
|
|
result += "\t" + "\"Windows\":[" + Environment.NewLine;
|
|
result += "\t\t{" + Environment.NewLine;
|
|
int Wcount = 0;
|
|
foreach (Window w in Windows)
|
|
{
|
|
result += "\t\t" + w.ToJSON();
|
|
Wcount++;
|
|
if (Wcount != Windows.Count)
|
|
result += ",";
|
|
}
|
|
result += "\t\t}" + Environment.NewLine;
|
|
result += "\t" + "]" + Environment.NewLine;
|
|
}
|
|
else
|
|
{
|
|
result += Environment.NewLine;
|
|
}
|
|
if (Zones.Count != 0)
|
|
{
|
|
result += "," + Environment.NewLine;
|
|
|
|
result += "\t" + "\"Zones\":[" + Environment.NewLine;
|
|
result += "\t\t{" + Environment.NewLine;
|
|
int Zcount = 0;
|
|
//foreach (Zone z in Zones)
|
|
//{
|
|
result += "\t\t" + Zones[0].ToJSON();
|
|
Zcount++;
|
|
if (Zcount != Zones.Count)
|
|
//result += ",";
|
|
//}
|
|
result += "\t\t}" + Environment.NewLine;
|
|
result += "\t" + "]" + Environment.NewLine;
|
|
}
|
|
else
|
|
{
|
|
result += Environment.NewLine;
|
|
}
|
|
|
|
result += "}";
|
|
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// Checks if the given Rectangle fits in the current zone
|
|
/// </summary>
|
|
/// <param name="InputRectangle">The Rectangle you want to check the fittment</param>
|
|
/// <returns></returns>
|
|
protected bool Fits(Rectangle inputRectangle)
|
|
{
|
|
if (inputRectangle.X + inputRectangle.Width > Bounds.Width || inputRectangle.Y + inputRectangle.Height > Bounds.Height || inputRectangle.X < 0 || inputRectangle.Y < 0)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
</code></pre>
|
|
</article>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<footer class="md-footer">
|
|
<nav aria-label="Footer" class="md-footer__inner md-grid">
|
|
<a aria-label="Previous: Reader.cs" class="md-footer__link md-footer__link--prev" href="../Reader/" rel="prev">
|
|
<div class="md-footer__button md-icon">
|
|
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"></path></svg>
|
|
</div>
|
|
<div class="md-footer__title">
|
|
<div class="md-ellipsis">
|
|
<span class="md-footer__direction">
|
|
Previous
|
|
</span>
|
|
Reader.cs
|
|
</div>
|
|
</div>
|
|
</a>
|
|
<a aria-label="Next: DriverDrsWindow.cs" class="md-footer__link md-footer__link--next" href="../DriverDrsWindow/" rel="next">
|
|
<div class="md-footer__title">
|
|
<div class="md-ellipsis">
|
|
<span class="md-footer__direction">
|
|
Next
|
|
</span>
|
|
DriverDrsWindow.cs
|
|
</div>
|
|
</div>
|
|
<div class="md-footer__button md-icon">
|
|
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"></path></svg>
|
|
</div>
|
|
</a>
|
|
</nav>
|
|
<div class="md-footer-meta md-typeset">
|
|
<div class="md-footer-meta__inner md-grid">
|
|
<div class="md-copyright">
|
|
<div class="md-copyright__highlight">
|
|
©CFPTI Tech2
|
|
</div>
|
|
|
|
|
|
Made with
|
|
<a href="https://squidfunk.github.io/mkdocs-material/" rel="noopener" target="_blank">
|
|
Material for MkDocs
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</div>
|
|
<div class="md-dialog" data-md-component="dialog">
|
|
<div class="md-dialog__inner md-typeset"></div>
|
|
</div>
|
|
<script id="__config" type="application/json">{"base": "../..", "features": [], "search": "../../assets/javascripts/workers/search.ecf98df9.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version.title": "Select version"}}</script>
|
|
<script src="../../assets/javascripts/bundle.48f2be22.min.js"></script>
|
|
<script>document$.subscribe(() => {const lightbox = GLightbox({"touchNavigation": true, "loop": false, "width": "100%", "height": "auto", "zoomable": true, "draggable": true, "openEffect": "zoom", "closeEffect": "zoom"});})</script></body>
|
|
</html> |