ajustado controle do pulverizador

This commit is contained in:
Diego Freitas 2025-02-21 16:50:54 -03:00
parent e22f73d820
commit 8a61d51b7d
35 changed files with 986 additions and 167 deletions

Binary file not shown.

View File

@ -1,6 +1,4 @@
using AForge.Video.DirectShow; using AgroBase.Models;
using AForge.Video;
using AgroBase.Models;
using AgroBase.Services; using AgroBase.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -197,7 +195,7 @@ namespace AgroBase.Forms.IHM
private void AtualizarCameras() private void AtualizarCameras()
{ {
flwCamerasSolo.Controls.Clear(); flwCamerasSolo.Controls.Clear();
Cameras = OAKCameraService.GetConnectedCameras(); Cameras = OAKCameraService.GetListaCameras();
for (int i = 0; i < Variaveis.OperacaoEmAndamento.QuantidadeCamerasSolo; i++) for (int i = 0; i < Variaveis.OperacaoEmAndamento.QuantidadeCamerasSolo; i++)
{ {
GerarCameraSolo(i); GerarCameraSolo(i);

View File

@ -186,7 +186,7 @@ namespace AgroBase.Forms.IHM
CodFalha = Variaveis.OperacaoEmAndamento.RetornaCodigoFalha(); CodFalha = Variaveis.OperacaoEmAndamento.RetornaCodigoFalha();
var Labels = this.Controls.OfType<Label>().Where(y => y.Name.Contains("lblD_")).ToList(); var Labels = this.Controls.OfType<Label>().Where(y => y.Name.Contains("lblD_")).ToList();
var listaCameras = OAKCameraService.GetConnectedCameras(); var listaCameras = OAKCameraService.GetListaCameras();
Labels.ForEach(lbl => Labels.ForEach(lbl =>
{ {
T_Code Dispositivo = (T_Code)Enum.Parse(typeof(T_Code), lbl.Name.Split('_')[1]); T_Code Dispositivo = (T_Code)Enum.Parse(typeof(T_Code), lbl.Name.Split('_')[1]);

View File

@ -49,6 +49,7 @@ namespace AgroBase.Forms.Operacoes
Width = 290, Width = 290,
Height = 166, Height = 166,
BackgroundImageLayout = ImageLayout.Stretch, BackgroundImageLayout = ImageLayout.Stretch,
BackColor = Color.Black,
}; };
flwCamerasSolo.Controls.Add(pnlCam); flwCamerasSolo.Controls.Add(pnlCam);
} }
@ -184,7 +185,7 @@ namespace AgroBase.Forms.Operacoes
chbMostrarGrade.Checked = false; chbMostrarGrade.Checked = false;
} }
bool atuadorAtivado = Variaveis.OperacaoEmAndamento.DispAtu.Dados.Conectado; bool atuadorAtivado = Variaveis.OperacaoEmAndamento.DispAtu.Dados.Conectado || true;
chbPulverizador.Enabled = atuadorAtivado; chbPulverizador.Enabled = atuadorAtivado;
if (!atuadorAtivado) if (!atuadorAtivado)
{ {

View File

@ -52,6 +52,9 @@
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea8 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea8 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend8 = new System.Windows.Forms.DataVisualization.Charting.Legend(); System.Windows.Forms.DataVisualization.Charting.Legend legend8 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series8 = new System.Windows.Forms.DataVisualization.Charting.Series(); System.Windows.Forms.DataVisualization.Charting.Series series8 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea9 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend9 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series9 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmResultadosOperacao)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmResultadosOperacao));
this.trbMomento = new System.Windows.Forms.TrackBar(); this.trbMomento = new System.Windows.Forms.TrackBar();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
@ -301,6 +304,7 @@
this.label30 = new System.Windows.Forms.Label(); this.label30 = new System.Windows.Forms.Label();
this.chartMovGeral = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.chartMovGeral = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.tabAtuador = new System.Windows.Forms.TabPage(); this.tabAtuador = new System.Windows.Forms.TabPage();
this.flwCameras = new System.Windows.Forms.FlowLayoutPanel();
this.lblATU_LatenciaLoop = new System.Windows.Forms.Label(); this.lblATU_LatenciaLoop = new System.Windows.Forms.Label();
this.lblATU_QualidadeWifi = new System.Windows.Forms.Label(); this.lblATU_QualidadeWifi = new System.Windows.Forms.Label();
this.chbDesenharErvas = new System.Windows.Forms.CheckBox(); this.chbDesenharErvas = new System.Windows.Forms.CheckBox();
@ -379,7 +383,7 @@
this.label101 = new System.Windows.Forms.Label(); this.label101 = new System.Windows.Forms.Label();
this.pnlCaminho = new System.Windows.Forms.Panel(); this.pnlCaminho = new System.Windows.Forms.Panel();
this.tabCPU = new System.Windows.Forms.TabPage(); this.tabCPU = new System.Windows.Forms.TabPage();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.gpbCpu_Analise = new System.Windows.Forms.GroupBox();
this.txtCpu_Maximo = new System.Windows.Forms.TextBox(); this.txtCpu_Maximo = new System.Windows.Forms.TextBox();
this.label107 = new System.Windows.Forms.Label(); this.label107 = new System.Windows.Forms.Label();
this.txtCpu_Minimo = new System.Windows.Forms.TextBox(); this.txtCpu_Minimo = new System.Windows.Forms.TextBox();
@ -457,7 +461,30 @@
this.label36 = new System.Windows.Forms.Label(); this.label36 = new System.Windows.Forms.Label();
this.txtMomento = new System.Windows.Forms.TextBox(); this.txtMomento = new System.Windows.Forms.TextBox();
this.btnPlay = new System.Windows.Forms.Button(); this.btnPlay = new System.Windows.Forms.Button();
this.flwCameras = new System.Windows.Forms.FlowLayoutPanel(); this.tabCameras = new System.Windows.Forms.TabPage();
this.gpbCameras_Analise = new System.Windows.Forms.GroupBox();
this.txtCameras_Maximo = new System.Windows.Forms.TextBox();
this.label121 = new System.Windows.Forms.Label();
this.txtCameras_Minimo = new System.Windows.Forms.TextBox();
this.label123 = new System.Windows.Forms.Label();
this.txtCameras_Media = new System.Windows.Forms.TextBox();
this.label125 = new System.Windows.Forms.Label();
this.txtCameras_Mediana = new System.Windows.Forms.TextBox();
this.label127 = new System.Windows.Forms.Label();
this.txtCameras_Atual = new System.Windows.Forms.TextBox();
this.txtCameras_Moda = new System.Windows.Forms.TextBox();
this.label128 = new System.Windows.Forms.Label();
this.label129 = new System.Windows.Forms.Label();
this.gpbCameras_Filtro = new System.Windows.Forms.GroupBox();
this.btnCameras_Proximo = new System.Windows.Forms.Button();
this.btnCameras_Anterior = new System.Windows.Forms.Button();
this.btnCameras_Redefinir = new System.Windows.Forms.Button();
this.btnCameras_Buscar = new System.Windows.Forms.Button();
this.cmbCameras_Componente = new System.Windows.Forms.ComboBox();
this.label130 = new System.Windows.Forms.Label();
this.cmbCameras_Filtro = new System.Windows.Forms.ComboBox();
this.label131 = new System.Windows.Forms.Label();
this.chartCameras = new System.Windows.Forms.DataVisualization.Charting.Chart();
((System.ComponentModel.ISupportInitialize)(this.trbMomento)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.trbMomento)).BeginInit();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.tabControl4.SuspendLayout(); this.tabControl4.SuspendLayout();
@ -518,12 +545,16 @@
((System.ComponentModel.ISupportInitialize)(this.gridObstaculos)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gridObstaculos)).BeginInit();
this.tabSegmentacao.SuspendLayout(); this.tabSegmentacao.SuspendLayout();
this.tabCPU.SuspendLayout(); this.tabCPU.SuspendLayout();
this.groupBox2.SuspendLayout(); this.gpbCpu_Analise.SuspendLayout();
this.gpbCpu_Filtro.SuspendLayout(); this.gpbCpu_Filtro.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chartCpu)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.chartCpu)).BeginInit();
this.panel6.SuspendLayout(); this.panel6.SuspendLayout();
this.pnlInformacoesOperacao.SuspendLayout(); this.pnlInformacoesOperacao.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picCameraCaminho)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picCameraCaminho)).BeginInit();
this.tabCameras.SuspendLayout();
this.gpbCameras_Analise.SuspendLayout();
this.gpbCameras_Filtro.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chartCameras)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// trbMomento // trbMomento
@ -913,6 +944,7 @@
this.tabControl1.Controls.Add(this.tabSonar); this.tabControl1.Controls.Add(this.tabSonar);
this.tabControl1.Controls.Add(this.tabSegmentacao); this.tabControl1.Controls.Add(this.tabSegmentacao);
this.tabControl1.Controls.Add(this.tabCPU); this.tabControl1.Controls.Add(this.tabCPU);
this.tabControl1.Controls.Add(this.tabCameras);
this.tabControl1.Location = new System.Drawing.Point(2, 2); this.tabControl1.Location = new System.Drawing.Point(2, 2);
this.tabControl1.Margin = new System.Windows.Forms.Padding(2); this.tabControl1.Margin = new System.Windows.Forms.Padding(2);
this.tabControl1.Name = "tabControl1"; this.tabControl1.Name = "tabControl1";
@ -3333,6 +3365,13 @@
this.tabAtuador.Text = "Atuador"; this.tabAtuador.Text = "Atuador";
this.tabAtuador.UseVisualStyleBackColor = true; this.tabAtuador.UseVisualStyleBackColor = true;
// //
// flwCameras
//
this.flwCameras.Location = new System.Drawing.Point(4, 18);
this.flwCameras.Name = "flwCameras";
this.flwCameras.Size = new System.Drawing.Size(489, 170);
this.flwCameras.TabIndex = 97;
//
// lblATU_LatenciaLoop // lblATU_LatenciaLoop
// //
this.lblATU_LatenciaLoop.AutoSize = true; this.lblATU_LatenciaLoop.AutoSize = true;
@ -4165,7 +4204,7 @@
// //
// tabCPU // tabCPU
// //
this.tabCPU.Controls.Add(this.groupBox2); this.tabCPU.Controls.Add(this.gpbCpu_Analise);
this.tabCPU.Controls.Add(this.gpbCpu_Filtro); this.tabCPU.Controls.Add(this.gpbCpu_Filtro);
this.tabCPU.Controls.Add(this.chartCpu); this.tabCPU.Controls.Add(this.chartCpu);
this.tabCPU.Location = new System.Drawing.Point(4, 22); this.tabCPU.Location = new System.Drawing.Point(4, 22);
@ -4176,28 +4215,28 @@
this.tabCPU.Text = "CPU"; this.tabCPU.Text = "CPU";
this.tabCPU.UseVisualStyleBackColor = true; this.tabCPU.UseVisualStyleBackColor = true;
// //
// groupBox2 // gpbCpu_Analise
// //
this.groupBox2.Controls.Add(this.txtCpu_Maximo); this.gpbCpu_Analise.Controls.Add(this.txtCpu_Maximo);
this.groupBox2.Controls.Add(this.label107); this.gpbCpu_Analise.Controls.Add(this.label107);
this.groupBox2.Controls.Add(this.txtCpu_Minimo); this.gpbCpu_Analise.Controls.Add(this.txtCpu_Minimo);
this.groupBox2.Controls.Add(this.label108); this.gpbCpu_Analise.Controls.Add(this.label108);
this.groupBox2.Controls.Add(this.txtCpu_Media); this.gpbCpu_Analise.Controls.Add(this.txtCpu_Media);
this.groupBox2.Controls.Add(this.label109); this.gpbCpu_Analise.Controls.Add(this.label109);
this.groupBox2.Controls.Add(this.txtCpu_Mediana); this.gpbCpu_Analise.Controls.Add(this.txtCpu_Mediana);
this.groupBox2.Controls.Add(this.label110); this.gpbCpu_Analise.Controls.Add(this.label110);
this.groupBox2.Controls.Add(this.txtCpu_Atual); this.gpbCpu_Analise.Controls.Add(this.txtCpu_Atual);
this.groupBox2.Controls.Add(this.txtCpu_Moda); this.gpbCpu_Analise.Controls.Add(this.txtCpu_Moda);
this.groupBox2.Controls.Add(this.label111); this.gpbCpu_Analise.Controls.Add(this.label111);
this.groupBox2.Controls.Add(this.label112); this.gpbCpu_Analise.Controls.Add(this.label112);
this.groupBox2.Location = new System.Drawing.Point(4, 396); this.gpbCpu_Analise.Location = new System.Drawing.Point(4, 396);
this.groupBox2.Margin = new System.Windows.Forms.Padding(2); this.gpbCpu_Analise.Margin = new System.Windows.Forms.Padding(2);
this.groupBox2.Name = "groupBox2"; this.gpbCpu_Analise.Name = "gpbCpu_Analise";
this.groupBox2.Padding = new System.Windows.Forms.Padding(2); this.gpbCpu_Analise.Padding = new System.Windows.Forms.Padding(2);
this.groupBox2.Size = new System.Drawing.Size(218, 123); this.gpbCpu_Analise.Size = new System.Drawing.Size(218, 123);
this.groupBox2.TabIndex = 136; this.gpbCpu_Analise.TabIndex = 136;
this.groupBox2.TabStop = false; this.gpbCpu_Analise.TabStop = false;
this.groupBox2.Text = "Análise"; this.gpbCpu_Analise.Text = "Análise";
// //
// txtCpu_Maximo // txtCpu_Maximo
// //
@ -5022,12 +5061,277 @@
this.btnPlay.UseVisualStyleBackColor = true; this.btnPlay.UseVisualStyleBackColor = true;
this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click); this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click);
// //
// flwCameras // tabCameras
// //
this.flwCameras.Location = new System.Drawing.Point(4, 18); this.tabCameras.Controls.Add(this.gpbCameras_Analise);
this.flwCameras.Name = "flwCameras"; this.tabCameras.Controls.Add(this.gpbCameras_Filtro);
this.flwCameras.Size = new System.Drawing.Size(489, 170); this.tabCameras.Controls.Add(this.chartCameras);
this.flwCameras.TabIndex = 97; this.tabCameras.Location = new System.Drawing.Point(4, 22);
this.tabCameras.Name = "tabCameras";
this.tabCameras.Padding = new System.Windows.Forms.Padding(3);
this.tabCameras.Size = new System.Drawing.Size(496, 522);
this.tabCameras.TabIndex = 11;
this.tabCameras.Text = "Câmeras";
this.tabCameras.UseVisualStyleBackColor = true;
//
// gpbCameras_Analise
//
this.gpbCameras_Analise.Controls.Add(this.txtCameras_Maximo);
this.gpbCameras_Analise.Controls.Add(this.label121);
this.gpbCameras_Analise.Controls.Add(this.txtCameras_Minimo);
this.gpbCameras_Analise.Controls.Add(this.label123);
this.gpbCameras_Analise.Controls.Add(this.txtCameras_Media);
this.gpbCameras_Analise.Controls.Add(this.label125);
this.gpbCameras_Analise.Controls.Add(this.txtCameras_Mediana);
this.gpbCameras_Analise.Controls.Add(this.label127);
this.gpbCameras_Analise.Controls.Add(this.txtCameras_Atual);
this.gpbCameras_Analise.Controls.Add(this.txtCameras_Moda);
this.gpbCameras_Analise.Controls.Add(this.label128);
this.gpbCameras_Analise.Controls.Add(this.label129);
this.gpbCameras_Analise.Location = new System.Drawing.Point(4, 396);
this.gpbCameras_Analise.Margin = new System.Windows.Forms.Padding(2);
this.gpbCameras_Analise.Name = "gpbCameras_Analise";
this.gpbCameras_Analise.Padding = new System.Windows.Forms.Padding(2);
this.gpbCameras_Analise.Size = new System.Drawing.Size(218, 123);
this.gpbCameras_Analise.TabIndex = 139;
this.gpbCameras_Analise.TabStop = false;
this.gpbCameras_Analise.Text = "Análise";
//
// txtCameras_Maximo
//
this.txtCameras_Maximo.Location = new System.Drawing.Point(143, 93);
this.txtCameras_Maximo.Margin = new System.Windows.Forms.Padding(2);
this.txtCameras_Maximo.Name = "txtCameras_Maximo";
this.txtCameras_Maximo.ReadOnly = true;
this.txtCameras_Maximo.Size = new System.Drawing.Size(65, 20);
this.txtCameras_Maximo.TabIndex = 131;
this.txtCameras_Maximo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label121
//
this.label121.AutoSize = true;
this.label121.Location = new System.Drawing.Point(141, 73);
this.label121.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label121.Name = "label121";
this.label121.Size = new System.Drawing.Size(43, 13);
this.label121.TabIndex = 132;
this.label121.Text = "Máximo";
//
// txtCameras_Minimo
//
this.txtCameras_Minimo.Location = new System.Drawing.Point(143, 53);
this.txtCameras_Minimo.Margin = new System.Windows.Forms.Padding(2);
this.txtCameras_Minimo.Name = "txtCameras_Minimo";
this.txtCameras_Minimo.ReadOnly = true;
this.txtCameras_Minimo.Size = new System.Drawing.Size(65, 20);
this.txtCameras_Minimo.TabIndex = 129;
this.txtCameras_Minimo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label123
//
this.label123.AutoSize = true;
this.label123.Location = new System.Drawing.Point(141, 32);
this.label123.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label123.Name = "label123";
this.label123.Size = new System.Drawing.Size(42, 13);
this.label123.TabIndex = 130;
this.label123.Text = "Mínimo";
//
// txtCameras_Media
//
this.txtCameras_Media.Location = new System.Drawing.Point(7, 93);
this.txtCameras_Media.Margin = new System.Windows.Forms.Padding(2);
this.txtCameras_Media.Name = "txtCameras_Media";
this.txtCameras_Media.ReadOnly = true;
this.txtCameras_Media.Size = new System.Drawing.Size(65, 20);
this.txtCameras_Media.TabIndex = 127;
this.txtCameras_Media.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label125
//
this.label125.AutoSize = true;
this.label125.Location = new System.Drawing.Point(4, 73);
this.label125.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label125.Name = "label125";
this.label125.Size = new System.Drawing.Size(36, 13);
this.label125.TabIndex = 128;
this.label125.Text = "Média";
//
// txtCameras_Mediana
//
this.txtCameras_Mediana.Location = new System.Drawing.Point(75, 93);
this.txtCameras_Mediana.Margin = new System.Windows.Forms.Padding(2);
this.txtCameras_Mediana.Name = "txtCameras_Mediana";
this.txtCameras_Mediana.ReadOnly = true;
this.txtCameras_Mediana.Size = new System.Drawing.Size(65, 20);
this.txtCameras_Mediana.TabIndex = 125;
this.txtCameras_Mediana.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label127
//
this.label127.AutoSize = true;
this.label127.Location = new System.Drawing.Point(73, 73);
this.label127.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label127.Name = "label127";
this.label127.Size = new System.Drawing.Size(48, 13);
this.label127.TabIndex = 126;
this.label127.Text = "Mediana";
//
// txtCameras_Atual
//
this.txtCameras_Atual.Location = new System.Drawing.Point(7, 53);
this.txtCameras_Atual.Margin = new System.Windows.Forms.Padding(2);
this.txtCameras_Atual.Name = "txtCameras_Atual";
this.txtCameras_Atual.ReadOnly = true;
this.txtCameras_Atual.Size = new System.Drawing.Size(65, 20);
this.txtCameras_Atual.TabIndex = 100;
this.txtCameras_Atual.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// txtCameras_Moda
//
this.txtCameras_Moda.Location = new System.Drawing.Point(75, 53);
this.txtCameras_Moda.Margin = new System.Windows.Forms.Padding(2);
this.txtCameras_Moda.Name = "txtCameras_Moda";
this.txtCameras_Moda.ReadOnly = true;
this.txtCameras_Moda.Size = new System.Drawing.Size(65, 20);
this.txtCameras_Moda.TabIndex = 102;
this.txtCameras_Moda.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label128
//
this.label128.AutoSize = true;
this.label128.Location = new System.Drawing.Point(73, 32);
this.label128.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label128.Name = "label128";
this.label128.Size = new System.Drawing.Size(34, 13);
this.label128.TabIndex = 124;
this.label128.Text = "Moda";
//
// label129
//
this.label129.AutoSize = true;
this.label129.Location = new System.Drawing.Point(4, 32);
this.label129.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label129.Name = "label129";
this.label129.Size = new System.Drawing.Size(31, 13);
this.label129.TabIndex = 123;
this.label129.Text = "Atual";
//
// gpbCameras_Filtro
//
this.gpbCameras_Filtro.Controls.Add(this.btnCameras_Proximo);
this.gpbCameras_Filtro.Controls.Add(this.btnCameras_Anterior);
this.gpbCameras_Filtro.Controls.Add(this.btnCameras_Redefinir);
this.gpbCameras_Filtro.Controls.Add(this.btnCameras_Buscar);
this.gpbCameras_Filtro.Controls.Add(this.cmbCameras_Componente);
this.gpbCameras_Filtro.Controls.Add(this.label130);
this.gpbCameras_Filtro.Controls.Add(this.cmbCameras_Filtro);
this.gpbCameras_Filtro.Controls.Add(this.label131);
this.gpbCameras_Filtro.Location = new System.Drawing.Point(356, 396);
this.gpbCameras_Filtro.Margin = new System.Windows.Forms.Padding(2);
this.gpbCameras_Filtro.Name = "gpbCameras_Filtro";
this.gpbCameras_Filtro.Padding = new System.Windows.Forms.Padding(2);
this.gpbCameras_Filtro.Size = new System.Drawing.Size(138, 123);
this.gpbCameras_Filtro.TabIndex = 138;
this.gpbCameras_Filtro.TabStop = false;
this.gpbCameras_Filtro.Text = "Filtro";
//
// btnCameras_Proximo
//
this.btnCameras_Proximo.Location = new System.Drawing.Point(112, 95);
this.btnCameras_Proximo.Margin = new System.Windows.Forms.Padding(2);
this.btnCameras_Proximo.Name = "btnCameras_Proximo";
this.btnCameras_Proximo.Size = new System.Drawing.Size(21, 23);
this.btnCameras_Proximo.TabIndex = 130;
this.btnCameras_Proximo.Text = ">";
this.btnCameras_Proximo.UseVisualStyleBackColor = true;
//
// btnCameras_Anterior
//
this.btnCameras_Anterior.Location = new System.Drawing.Point(32, 95);
this.btnCameras_Anterior.Margin = new System.Windows.Forms.Padding(2);
this.btnCameras_Anterior.Name = "btnCameras_Anterior";
this.btnCameras_Anterior.Size = new System.Drawing.Size(21, 23);
this.btnCameras_Anterior.TabIndex = 129;
this.btnCameras_Anterior.Text = "<";
this.btnCameras_Anterior.UseVisualStyleBackColor = true;
//
// btnCameras_Redefinir
//
this.btnCameras_Redefinir.Location = new System.Drawing.Point(7, 95);
this.btnCameras_Redefinir.Margin = new System.Windows.Forms.Padding(2);
this.btnCameras_Redefinir.Name = "btnCameras_Redefinir";
this.btnCameras_Redefinir.Size = new System.Drawing.Size(21, 23);
this.btnCameras_Redefinir.TabIndex = 128;
this.btnCameras_Redefinir.Text = "X";
this.btnCameras_Redefinir.UseVisualStyleBackColor = true;
//
// btnCameras_Buscar
//
this.btnCameras_Buscar.Location = new System.Drawing.Point(58, 95);
this.btnCameras_Buscar.Margin = new System.Windows.Forms.Padding(2);
this.btnCameras_Buscar.Name = "btnCameras_Buscar";
this.btnCameras_Buscar.Size = new System.Drawing.Size(50, 23);
this.btnCameras_Buscar.TabIndex = 127;
this.btnCameras_Buscar.Text = "Buscar";
this.btnCameras_Buscar.UseVisualStyleBackColor = true;
//
// cmbCameras_Componente
//
this.cmbCameras_Componente.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCameras_Componente.FormattingEnabled = true;
this.cmbCameras_Componente.Location = new System.Drawing.Point(7, 71);
this.cmbCameras_Componente.Margin = new System.Windows.Forms.Padding(2);
this.cmbCameras_Componente.Name = "cmbCameras_Componente";
this.cmbCameras_Componente.Size = new System.Drawing.Size(128, 21);
this.cmbCameras_Componente.TabIndex = 126;
//
// label130
//
this.label130.AutoSize = true;
this.label130.Location = new System.Drawing.Point(4, 55);
this.label130.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label130.Name = "label130";
this.label130.Size = new System.Drawing.Size(67, 13);
this.label130.TabIndex = 125;
this.label130.Text = "Componente";
//
// cmbCameras_Filtro
//
this.cmbCameras_Filtro.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCameras_Filtro.FormattingEnabled = true;
this.cmbCameras_Filtro.Location = new System.Drawing.Point(7, 33);
this.cmbCameras_Filtro.Margin = new System.Windows.Forms.Padding(2);
this.cmbCameras_Filtro.Name = "cmbCameras_Filtro";
this.cmbCameras_Filtro.Size = new System.Drawing.Size(128, 21);
this.cmbCameras_Filtro.TabIndex = 124;
//
// label131
//
this.label131.AutoSize = true;
this.label131.Location = new System.Drawing.Point(4, 18);
this.label131.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label131.Name = "label131";
this.label131.Size = new System.Drawing.Size(58, 13);
this.label131.TabIndex = 123;
this.label131.Text = "Buscar por";
//
// chartCameras
//
chartArea9.Name = "ChartArea1";
this.chartCameras.ChartAreas.Add(chartArea9);
legend9.Name = "Legend1";
this.chartCameras.Legends.Add(legend9);
this.chartCameras.Location = new System.Drawing.Point(2, 3);
this.chartCameras.Margin = new System.Windows.Forms.Padding(2);
this.chartCameras.Name = "chartCameras";
series9.ChartArea = "ChartArea1";
series9.Legend = "Legend1";
series9.Name = "Series1";
this.chartCameras.Series.Add(series9);
this.chartCameras.Size = new System.Drawing.Size(491, 389);
this.chartCameras.TabIndex = 137;
this.chartCameras.Text = "chart1";
// //
// frmResultadosOperacao // frmResultadosOperacao
// //
@ -5133,8 +5437,8 @@
this.tabSegmentacao.ResumeLayout(false); this.tabSegmentacao.ResumeLayout(false);
this.tabSegmentacao.PerformLayout(); this.tabSegmentacao.PerformLayout();
this.tabCPU.ResumeLayout(false); this.tabCPU.ResumeLayout(false);
this.groupBox2.ResumeLayout(false); this.gpbCpu_Analise.ResumeLayout(false);
this.groupBox2.PerformLayout(); this.gpbCpu_Analise.PerformLayout();
this.gpbCpu_Filtro.ResumeLayout(false); this.gpbCpu_Filtro.ResumeLayout(false);
this.gpbCpu_Filtro.PerformLayout(); this.gpbCpu_Filtro.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.chartCpu)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.chartCpu)).EndInit();
@ -5142,6 +5446,12 @@
this.pnlInformacoesOperacao.ResumeLayout(false); this.pnlInformacoesOperacao.ResumeLayout(false);
this.pnlInformacoesOperacao.PerformLayout(); this.pnlInformacoesOperacao.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picCameraCaminho)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picCameraCaminho)).EndInit();
this.tabCameras.ResumeLayout(false);
this.gpbCameras_Analise.ResumeLayout(false);
this.gpbCameras_Analise.PerformLayout();
this.gpbCameras_Filtro.ResumeLayout(false);
this.gpbCameras_Filtro.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.chartCameras)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -5456,7 +5766,7 @@
private System.Windows.Forms.TextBox txtTemperatura; private System.Windows.Forms.TextBox txtTemperatura;
private System.Windows.Forms.Label label104; private System.Windows.Forms.Label label104;
private System.Windows.Forms.TabPage tabCPU; private System.Windows.Forms.TabPage tabCPU;
private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox gpbCpu_Analise;
private System.Windows.Forms.TextBox txtCpu_Maximo; private System.Windows.Forms.TextBox txtCpu_Maximo;
private System.Windows.Forms.Label label107; private System.Windows.Forms.Label label107;
private System.Windows.Forms.TextBox txtCpu_Minimo; private System.Windows.Forms.TextBox txtCpu_Minimo;
@ -5554,5 +5864,29 @@
private System.Windows.Forms.TextBox txtDIR_AgPot_ET; private System.Windows.Forms.TextBox txtDIR_AgPot_ET;
private System.Windows.Forms.Label lblDIR_AgPot_ET; private System.Windows.Forms.Label lblDIR_AgPot_ET;
private System.Windows.Forms.FlowLayoutPanel flwCameras; private System.Windows.Forms.FlowLayoutPanel flwCameras;
private System.Windows.Forms.TabPage tabCameras;
private System.Windows.Forms.GroupBox gpbCameras_Analise;
private System.Windows.Forms.TextBox txtCameras_Maximo;
private System.Windows.Forms.Label label121;
private System.Windows.Forms.TextBox txtCameras_Minimo;
private System.Windows.Forms.Label label123;
private System.Windows.Forms.TextBox txtCameras_Media;
private System.Windows.Forms.Label label125;
private System.Windows.Forms.TextBox txtCameras_Mediana;
private System.Windows.Forms.Label label127;
private System.Windows.Forms.TextBox txtCameras_Atual;
private System.Windows.Forms.TextBox txtCameras_Moda;
private System.Windows.Forms.Label label128;
private System.Windows.Forms.Label label129;
private System.Windows.Forms.GroupBox gpbCameras_Filtro;
private System.Windows.Forms.Button btnCameras_Proximo;
private System.Windows.Forms.Button btnCameras_Anterior;
private System.Windows.Forms.Button btnCameras_Redefinir;
private System.Windows.Forms.Button btnCameras_Buscar;
private System.Windows.Forms.ComboBox cmbCameras_Componente;
private System.Windows.Forms.Label label130;
private System.Windows.Forms.ComboBox cmbCameras_Filtro;
private System.Windows.Forms.Label label131;
public System.Windows.Forms.DataVisualization.Charting.Chart chartCameras;
} }
} }

View File

@ -59,6 +59,7 @@ namespace AgroBase.Forms.Operacoes
GraficoInterativoModel graficoAtu; GraficoInterativoModel graficoAtu;
GraficoInterativoModel graficoSen; GraficoInterativoModel graficoSen;
GraficoInterativoModel graficoCpu; GraficoInterativoModel graficoCpu;
GraficoInterativoModel graficoCameras;
GraficoInterativoModel graficoErvas; GraficoInterativoModel graficoErvas;
@ -601,7 +602,6 @@ namespace AgroBase.Forms.Operacoes
}, },
}); });
// Obtemos todos os tipos de ervas identificadas ao longo dos logs // Obtemos todos os tipos de ervas identificadas ao longo dos logs
var todasErvas = LogsOperacao var todasErvas = LogsOperacao
.SelectMany(log => log.Atuador.ErvasIdentificadas) .SelectMany(log => log.Atuador.ErvasIdentificadas)
@ -659,6 +659,74 @@ namespace AgroBase.Forms.Operacoes
Titulo = "Ervas Identificadas" Titulo = "Ervas Identificadas"
}; };
List<GraficoInterativoSerieModel> seriesCamerasSolo = new List<GraficoInterativoSerieModel>();
foreach (var camSolo in LogsCam_Solo)
{
string camNome = "Solo " + (LogsCam_Solo.IndexOf(camSolo) + 1);
seriesCamerasSolo.AddRange(new List<GraficoInterativoSerieModel>()
{
new GraficoInterativoSerieModel()
{
Titulo = $"{camNome} RAM %",
Valores = camSolo.Select(x => (double)(x?.Leitura.device_data.Memory_Usage.Percent ?? 0)).ToList(),
Visivel = true,
},
new GraficoInterativoSerieModel()
{
Titulo = $"{camNome} CPU Temp",
Valores = camSolo.Select(x => (double)(x?.Leitura.device_data.Temperature.css ?? 0)).ToList(),
Visivel = true,
},
new GraficoInterativoSerieModel()
{
Titulo = $"{camNome} RAM Temp",
Valores = camSolo.Select(x => (double)(x?.Leitura.device_data.Temperature.mss ?? 0)).ToList(),
Visivel = true,
},
new GraficoInterativoSerieModel()
{
Titulo = $"{camNome} VCC Temp",
Valores = camSolo.Select(x => (double)(x?.Leitura.device_data.Temperature.upa ?? 0)).ToList(),
Visivel = true,
}
});
}
if (LogsCam_Caminho.Any(x => x.Leitura.device_data != null))
{
var camCaminho = LogsCam_Caminho;
string camNome = "Caminho";
seriesCamerasSolo.AddRange(new List<GraficoInterativoSerieModel>()
{
new GraficoInterativoSerieModel()
{
Titulo = $"{camNome} RAM %",
Valores = camCaminho.Select(x => (double)(x?.Leitura.device_data.Memory_Usage.Percent ?? 0)).ToList(),
Visivel = true,
},
new GraficoInterativoSerieModel()
{
Titulo = $"{camNome} CPU Temp",
Valores = camCaminho.Select(x => (double)(x?.Leitura.device_data.Temperature.css ?? 0)).ToList(),
Visivel = true,
},
new GraficoInterativoSerieModel()
{
Titulo = $"{camNome} RAM Temp",
Valores = camCaminho.Select(x => (double)(x?.Leitura.device_data.Temperature.mss ?? 0)).ToList(),
Visivel = true,
},
new GraficoInterativoSerieModel()
{
Titulo = $"{camNome} VCC Temp",
Valores = camCaminho.Select(x => (double)(x?.Leitura.device_data.Temperature.upa ?? 0)).ToList(),
Visivel = true,
}
});
}
graficoCameras = new GraficoInterativoModel(chartCameras, Momentos, seriesCamerasSolo);
} }
private void InicializarCombosBusca() private void InicializarCombosBusca()
@ -667,6 +735,7 @@ namespace AgroBase.Forms.Operacoes
CarregarInformacoesBusca(gpbMOV_Geral_Filtro, graficoMovGeral.Series.Select(x => x.Titulo).ToArray()); CarregarInformacoesBusca(gpbMOV_Geral_Filtro, graficoMovGeral.Series.Select(x => x.Titulo).ToArray());
CarregarInformacoesBusca(gpbSEN_Filtro, graficoSen.Series.Select(x => x.Titulo).ToArray()); CarregarInformacoesBusca(gpbSEN_Filtro, graficoSen.Series.Select(x => x.Titulo).ToArray());
CarregarInformacoesBusca(gpbCpu_Filtro, graficoCpu.Series.Select(x => x.Titulo).ToArray()); CarregarInformacoesBusca(gpbCpu_Filtro, graficoCpu.Series.Select(x => x.Titulo).ToArray());
CarregarInformacoesBusca(gpbCameras_Filtro, graficoCameras.Series.Select(x => x.Titulo).ToArray());
} }
private void CarregarInformacoesBusca(GroupBox gpb, string[] Componentes) private void CarregarInformacoesBusca(GroupBox gpb, string[] Componentes)
@ -754,10 +823,14 @@ namespace AgroBase.Forms.Operacoes
{ {
grafico = graficoMovGeral; grafico = graficoMovGeral;
} }
if (gpb.Name.Contains("Cpu")) else if (gpb.Name.Contains("Cpu"))
{ {
grafico = graficoCpu; grafico = graficoCpu;
} }
else if (gpb.Name.Contains("Cameras"))
{
grafico = graficoCameras;
}
if (grafico != null) if (grafico != null)
{ {
var Dados = grafico.Series.FirstOrDefault(x => x.Titulo == cmbComponente.Text).Valores.Select((x, i) => new { valor = x, idx = i }).ToList(); var Dados = grafico.Series.FirstOrDefault(x => x.Titulo == cmbComponente.Text).Valores.Select((x, i) => new { valor = x, idx = i }).ToList();
@ -959,6 +1032,20 @@ namespace AgroBase.Forms.Operacoes
picsCamSolo[i].Image = bitmapSolo; picsCamSolo[i].Image = bitmapSolo;
} }
} }
graficoCameras.AtualizarDados(idxMomentoAtual);
if (cmbCameras_Componente.SelectedIndex > -1)
{
var Valores = graficoCameras.Series.FirstOrDefault(x => x.Titulo == cmbCameras_Componente.Text).Valores.Take(idxMomentoAtual + 1).ToList();
txtCameras_Atual.Text = Valores[idxMomentoAtual].ToString("0.00");
txtCameras_Media.Text = Valores.Average().ToString("0.00");
txtCameras_Mediana.Text = FuncoesMatematicas.CalcularMediana(Valores).ToString("0.00");
txtCameras_Moda.Text = FuncoesMatematicas.CalcularModa(Valores).ToString("0.00");
txtCameras_Minimo.Text = Valores.Min().ToString("0.00");
txtCameras_Maximo.Text = Valores.Max().ToString("0.00");
}
} }
private void AtualizarInformacoesGPS() private void AtualizarInformacoesGPS()
@ -1289,6 +1376,7 @@ namespace AgroBase.Forms.Operacoes
} }
private void pnlOrientacaoDirecional_Paint(object sender, PaintEventArgs e) private void pnlOrientacaoDirecional_Paint(object sender, PaintEventArgs e)
{ {
var LogOp = LogsOperacao.FirstOrDefault(x => x.Momento == MomentoAtual); var LogOp = LogsOperacao.FirstOrDefault(x => x.Momento == MomentoAtual);

View File

@ -34,6 +34,8 @@ namespace AgroBase.Forms
WifiService.IniciarRotinas(); WifiService.IniciarRotinas();
APIService.IniciarRotinas(); APIService.IniciarRotinas();
OAKCameraService.IniciarRotinas();
GeneralJoystick.IniciarRotinas(); GeneralJoystick.IniciarRotinas();
VersionamentoService.IniciarRotinas(); VersionamentoService.IniciarRotinas();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace AgroBase.Models namespace AgroBase.Models
{ {
@ -17,6 +18,19 @@ namespace AgroBase.Models
public double x_max { get; set; } public double x_max { get; set; }
public double y_max { get; set; } public double y_max { get; set; }
public CameraCoordenadasObjetoModel[] objetos { get; set; } = new List<CameraCoordenadasObjetoModel>().ToArray(); public CameraCoordenadasObjetoModel[] objetos { get; set; } = new List<CameraCoordenadasObjetoModel>().ToArray();
public OAKCameraModel device_data { get; set; } = new OAKCameraModel();
public CameraCoordenadasFrameModel Clone()
{
return new CameraCoordenadasFrameModel()
{
timestamp = timestamp,
x_max = x_max,
y_max = y_max,
objetos = objetos.ToArray(),
device_data = device_data?.Clone()
};
}
} }
public class CameraCoordenadasObjetoModel public class CameraCoordenadasObjetoModel
@ -41,7 +55,18 @@ namespace AgroBase.Models
public class CameraDeepLabV3PlusModel public class CameraDeepLabV3PlusModel
{ {
public double timestamp { get; set; } public double timestamp { get; set; }
public OAKCameraModel device_data { get; set; }
public List<CameraDeepLabV3PlusClasseModel> Classes { get; set; } = new List<CameraDeepLabV3PlusClasseModel>(); public List<CameraDeepLabV3PlusClasseModel> Classes { get; set; } = new List<CameraDeepLabV3PlusClasseModel>();
public CameraDeepLabV3PlusModel Clone()
{
return new CameraDeepLabV3PlusModel()
{
timestamp = timestamp,
device_data = device_data?.Clone(),
Classes = new List<CameraDeepLabV3PlusClasseModel>(Classes)
};
}
} }
public class CameraDeepLabV3PlusClasseModel public class CameraDeepLabV3PlusClasseModel

View File

@ -1,10 +1,81 @@
namespace AgroBase.Models using System;
namespace AgroBase.Models
{ {
public class OAKCameraModel public class OAKCameraModel
{ {
public int Index { get; set; } public int Index { get; set; }
public string Id { get; set; } public string Id { get; set; }
public string Model { get; set; } public string Name { get; set; }
public string State { get; set; }
public string Usb_Speed { get; set; } public string Usb_Speed { get; set; }
public string[] Available_Camera_Sensors { get; set; }
public string Version { get; set; }
public OAKCameraMemoryUsageModel Memory_Usage { get; set; }
public OAKCameraTemperaturaModel Temperature { get; set; }
public string Bootloader_Version { get; set; }
public bool Is_Pipeline_Running { get; set; }
public OAKCameraModel Clone()
{
return new OAKCameraModel()
{
Index = Index,
Id = Id,
Name = Name,
State = State,
Usb_Speed = Usb_Speed,
Available_Camera_Sensors = Available_Camera_Sensors,
Bootloader_Version = Bootloader_Version,
Is_Pipeline_Running = Is_Pipeline_Running,
Memory_Usage = Memory_Usage?.Clone(),
Temperature = Temperature?.Clone(),
Version = Version
};
}
} }
public class OAKCameraMemoryUsageModel
{
public double Remaining { get; set; }
public double Total { get; set; }
public double Used { get; set; }
public double Percent
{
get
{
return Math.Round((Used / Total) * 100, 2);
}
}
public OAKCameraMemoryUsageModel Clone()
{
return new OAKCameraMemoryUsageModel()
{
Remaining = Remaining,
Total = Total,
Used = Used
};
}
}
public class OAKCameraTemperaturaModel
{
public double css { get; set; }
public double mss { get; set; }
public double upa { get; set; }
public double dss { get; set; }
public OAKCameraTemperaturaModel Clone()
{
return new OAKCameraTemperaturaModel()
{
css = css,
mss = mss,
upa = upa,
dss = dss
};
}
}
} }

View File

@ -986,7 +986,7 @@ namespace AgroBase.Models
} }
//var listaCameras = CameraService.ObterListaCameras().Values.ToArray(); //var listaCameras = CameraService.ObterListaCameras().Values.ToArray();
var listaCameras = OAKCameraService.GetConnectedCameras(); var listaCameras = OAKCameraService.GetListaCameras();
CamerasSolo.ForEach(cam => cam.DesligarCamera()); CamerasSolo.ForEach(cam => cam.DesligarCamera());
@ -996,7 +996,7 @@ namespace AgroBase.Models
string CamNome = "Cam_Solo_" + i.ToString(); string CamNome = "Cam_Solo_" + i.ToString();
string deviceId = string deviceId =
pnlCameraSolo.Count() > i && pnlCameraSolo[i].Tag != null && !string.IsNullOrEmpty(pnlCameraSolo[i].Tag.ToString()) ? pnlCameraSolo[i].Tag.ToString() : pnlCameraSolo.Count(x => x != null) > i && pnlCameraSolo[i].Tag != null && !string.IsNullOrEmpty(pnlCameraSolo[i].Tag.ToString()) ? pnlCameraSolo[i].Tag.ToString() :
DispSen.Dados.CameraID_Solo.Count > i ? DispSen.Dados.CameraID_Solo[i] : DispSen.Dados.CameraID_Solo.Count > i ? DispSen.Dados.CameraID_Solo[i] :
null; null;
@ -1091,10 +1091,12 @@ namespace AgroBase.Models
CameraSolo.browser = new ChromiumWebBrowser(CameraSolo.camera.URLcamera); CameraSolo.browser = new ChromiumWebBrowser(CameraSolo.camera.URLcamera);
CameraSolo.browser.Dock = DockStyle.Fill; CameraSolo.browser.Dock = DockStyle.Fill;
CameraSolo.panel.Invoke(new Action(() => CameraSolo.panel.Invoke(new Action(async () =>
{ {
CameraSolo.panel.Controls.Add(CameraSolo.browser); CameraSolo.panel.Controls.Add(CameraSolo.browser);
CameraSolo.panel.Refresh(); CameraSolo.panel.Refresh();
await Task.Delay(500);
CameraSolo.panel.Refresh();
})); }));
} }
} }
@ -1481,9 +1483,9 @@ namespace AgroBase.Models
CameraSolo.Leitura = JsonConvert.DeserializeObject<CameraCoordenadasFrameModel>(Mensagem.Mensagem); CameraSolo.Leitura = JsonConvert.DeserializeObject<CameraCoordenadasFrameModel>(Mensagem.Mensagem);
} }
} }
catch catch (Exception ex)
{ {
Console.WriteLine("Erro ao parsear json da camera solo: " + ex.Message);
} }
var Atuador = Variaveis.OperacaoEmAndamento.DispAtu; var Atuador = Variaveis.OperacaoEmAndamento.DispAtu;
@ -2044,13 +2046,13 @@ namespace AgroBase.Models
{ {
tipo = typeof(CamSoloSensoriamentoLogModel), tipo = typeof(CamSoloSensoriamentoLogModel),
nome = x.Nome, nome = x.Nome,
browser = x.browser, browser = x.browser
}) })
.Union(new[] { .Union(new[] {
new { new {
tipo = typeof(CamCaminhoSensoriamentoLogModel), tipo = typeof(CamCaminhoSensoriamentoLogModel),
nome = cameraCaminho.Nome, nome = cameraCaminho.Nome,
browser = cameraCaminho.browser, browser = cameraCaminho.browser
} }
}) })
.ToList(); .ToList();
@ -2073,13 +2075,7 @@ namespace AgroBase.Models
CamSoloSensoriamentoLogModel logCam = new CamSoloSensoriamentoLogModel() CamSoloSensoriamentoLogModel logCam = new CamSoloSensoriamentoLogModel()
{ {
Momento = Agora, Momento = Agora,
Leitura = new CameraCoordenadasFrameModel() Leitura = leitura.Clone()
{
timestamp = leitura.timestamp,
x_max = leitura.x_max,
y_max = leitura.y_max,
objetos = leitura.objetos.ToArray(),
}
}; };
SalvarLog(Camera.nome, logCam, false); SalvarLog(Camera.nome, logCam, false);
@ -2097,16 +2093,7 @@ namespace AgroBase.Models
Angulo = cameraCaminho.Angulo, Angulo = cameraCaminho.Angulo,
AnguloDireito = cameraCaminho.AnguloDireito, AnguloDireito = cameraCaminho.AnguloDireito,
AnguloEsquerdo = cameraCaminho.AnguloEsquerdo, AnguloEsquerdo = cameraCaminho.AnguloEsquerdo,
Leitura = new CameraDeepLabV3PlusModel() Leitura = leitura.Clone()
{
timestamp = leitura.timestamp,
Classes = leitura.Classes.Select(x => new CameraDeepLabV3PlusClasseModel()
{
Classe = x.Classe,
Contornos = x.Contornos.ToArray(),
})
.ToList()
}
}; };
SalvarLog(Camera.nome, logCam, false); SalvarLog(Camera.nome, logCam, false);

View File

@ -8,16 +8,24 @@ namespace AgroBase.Services
{ {
public class OAKCameraService public class OAKCameraService
{ {
public static List<OAKCameraModel> GetConnectedCameras() public static List<OAKCameraModel> CamerasConectadas = new List<OAKCameraModel>();
private static readonly object Cameras_Lock = new object();
private static AsyncTaskTimerModel tmrAtualizacao = new AsyncTaskTimerModel("tmrAtualizacao_OAK", async () => { AtualizarListaCameras(); }, 5000);
public static void IniciarRotinas()
{
tmrAtualizacao?.Stop();
tmrAtualizacao?.Start();
}
private static void AtualizarListaCameras()
{ {
var cameras = new List<OAKCameraModel>() var cameras = new List<OAKCameraModel>()
{ {
new OAKCameraModel() new OAKCameraModel()
{ {
Id = "Sem video", Id = "Sem video",
Index = -1, Index = -1
Model = "",
Usb_Speed = ""
} }
}; };
@ -28,7 +36,6 @@ namespace AgroBase.Services
if (string.IsNullOrWhiteSpace(output)) if (string.IsNullOrWhiteSpace(output))
{ {
Console.WriteLine("Nenhuma saída do script Python."); Console.WriteLine("Nenhuma saída do script Python.");
return cameras;
} }
// Converte o JSON para uma lista de objetos OakCamera // Converte o JSON para uma lista de objetos OakCamera
@ -36,12 +43,24 @@ namespace AgroBase.Services
cameras.AddRange(_cameras); cameras.AddRange(_cameras);
return cameras; lock (Cameras_Lock)
{
CamerasConectadas = new List<OAKCameraModel>(cameras);
}
Console.WriteLine("Lista de cameras atualizadas: " + cameras.Count);
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"Erro ao executar script Python: {ex.Message}"); Console.WriteLine($"Erro ao executar script Python: {ex.Message}");
return cameras; }
}
public static List<OAKCameraModel> GetListaCameras()
{
lock (Cameras_Lock)
{
return new List<OAKCameraModel>(CamerasConectadas);
} }
} }
} }

View File

@ -81,8 +81,8 @@ namespace AgroBase.Services
FileName = "python", FileName = "python",
Arguments = $"{ScriptPath} {Args}", Arguments = $"{ScriptPath} {Args}",
UseShellExecute = false, UseShellExecute = false,
RedirectStandardOutput = true, RedirectStandardOutput = false,
RedirectStandardError = true, RedirectStandardError = false,
CreateNoWindow = true, CreateNoWindow = true,
Verb = Variaveis.NomeAplicacao Verb = Variaveis.NomeAplicacao
} }

View File

@ -1 +1 @@
{"tmrRegistrador":{"_uiControl":null,"State":2,"IsRunning":false,"IsStopped":true,"IsCreated":false,"Interval":500,"StackTrace":"AtuadorModel.IniciarRegistrador","Id":"tmrRegistrador_Atu","TimeTick":"00:00:00"},"Modulo_ID":"Atu","IP":"192.168.100.13","RequisitarDados":true,"Conectado":false,"QuantidadeBicos":4,"DensidadeHerbicida":1.05,"BicosPulverizadores":[{"ID":"B01","Posicao":1,"Componente":422,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B02","Posicao":2,"Componente":422,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B03","Posicao":3,"Componente":422,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B04","Posicao":4,"Componente":422,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0}],"BombasPressurizadoras":[{"ID":"BOMBA","ComandoAtuar":false,"Componente":325,"LeituraEstado":false,"Comandar":true,"Testando":false,"Funcoes":[14,35,36,37,5],"LeituraPotencia":0.0,"LeituraPressaoSP":0.0,"LeituraPressao":0.0,"Leitura":null,"Inicializado":false}],"Sensores":[{"LogGrafico":[],"ID":"FLXLN","Prioridade":23,"Descricao":"Fluxo na linha principal","Componente":198,"Aferir":true,"DelayAmostragem":300,"Leitura":null,"Inicializado":false,"Testando":false,"Funcoes":[25],"Parametros":[],"UnidadeMedida":"mL/s","LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"MASRS","Prioridade":3,"Descricao":"Massa do reservatório de herbicida","Componente":532,"Aferir":true,"DelayAmostragem":1000,"Leitura":null,"Inicializado":false,"Testando":false,"Funcoes":[22,23],"Parametros":[],"UnidadeMedida":"Kg","LimiteMaximo":50.0,"LimiteMinimo":5.0},{"LogGrafico":[],"ID":"PRSLN","Prioridade":3,"Descricao":"Pressão na linha principal","Componente":333,"Aferir":true,"DelayAmostragem":1000,"Leitura":null,"Inicializado":false,"Testando":false,"Funcoes":[24],"Parametros":[["Vmin","000.00"],["Vmax","004.50"],["Pmax","174.04"]],"UnidadeMedida":"psi","LimiteMaximo":120.0,"LimiteMinimo":60.0}],"BombaPressurizadora":{"ID":"BOMBA","ComandoAtuar":false,"Componente":325,"LeituraEstado":false,"Comandar":true,"Testando":false,"Funcoes":[14,35,36,37,5],"LeituraPotencia":0.0,"LeituraPressaoSP":0.0,"LeituraPressao":0.0,"Leitura":null,"Inicializado":false},"ScriptDeteccaoErvas":"weed_detector_oak-1_0.py","DadosLeitura":{"Momento":"0001-01-01T00:00:00","Conectado":false,"Mod_ID":null,"QualidadeWifi":0,"LatenciaLoop":0,"BicosPulverizadores":[],"BombasPressurizadoras":[],"SensoresFluxo":[],"SensoresMassa":[],"SensoresPressao":[]},"_MassaRef":0.8,"_MassaLeituraRef":40876.37,"_MassaLeituraExtra":1895800.0,"MassaReservatorio":0.0,"VolumeReservatorio":0.0,"PercentualReservatorio":0.0,"VolumeVazaoAferido":0.0,"_FluxoMlRef":102.0,"_FluxoPulsoRef":80.0,"VazaoFluxoMLpSInstantanea":0.0,"VazaoFluxoMLpSMedia":0.0,"VolumeVazaoML":0.0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0,"_PressaoVmin":0.0,"_PressaoVmax":4.5,"_PressaoMax":174.045,"PressaoLinha":0.0,"PressaoLinhaCalc":0.0,"PercentualErvasTerreno":0.0} {"tmrRegistrador":{"_uiControl":null,"State":2,"IsRunning":false,"IsStopped":true,"IsCreated":false,"Interval":500,"StackTrace":"AtuadorModel.IniciarRegistrador","Id":"tmrRegistrador_Atu","TimeTick":"00:00:00"},"Modulo_ID":"Atu","IP":"192.168.100.13","RequisitarDados":true,"Conectado":false,"QuantidadeBicos":4,"DensidadeHerbicida":1.05,"BicosPulverizadores":[{"ID":"B01","Posicao":1,"Componente":422,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B02","Posicao":2,"Componente":422,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B03","Posicao":3,"Componente":422,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":2.2843163884147217,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B04","Posicao":4,"Componente":422,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0}],"BombasPressurizadoras":[{"ID":"BOMBA","ComandoAtuar":false,"Componente":325,"LeituraEstado":false,"Comandar":true,"Testando":false,"Funcoes":[14,35,36,37,5],"LeituraPotencia":0.0,"LeituraPressaoSP":0.0,"LeituraPressao":0.0,"Leitura":null,"Inicializado":false}],"Sensores":[{"LogGrafico":[],"ID":"FLXLN","Prioridade":23,"Descricao":"Fluxo na linha principal","Componente":198,"Aferir":true,"DelayAmostragem":300,"Leitura":null,"Inicializado":false,"Testando":false,"Funcoes":[25],"Parametros":[],"UnidadeMedida":"mL/s","LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"MASRS","Prioridade":3,"Descricao":"Massa do reservatório de herbicida","Componente":532,"Aferir":true,"DelayAmostragem":1000,"Leitura":null,"Inicializado":false,"Testando":false,"Funcoes":[22,23],"Parametros":[],"UnidadeMedida":"Kg","LimiteMaximo":50.0,"LimiteMinimo":5.0},{"LogGrafico":[],"ID":"PRSLN","Prioridade":3,"Descricao":"Pressão na linha principal","Componente":333,"Aferir":true,"DelayAmostragem":1000,"Leitura":null,"Inicializado":false,"Testando":false,"Funcoes":[24],"Parametros":[["Vmin","000.00"],["Vmax","004.50"],["Pmax","174.04"]],"UnidadeMedida":"psi","LimiteMaximo":120.0,"LimiteMinimo":60.0}],"BombaPressurizadora":{"ID":"BOMBA","ComandoAtuar":false,"Componente":325,"LeituraEstado":false,"Comandar":true,"Testando":false,"Funcoes":[14,35,36,37,5],"LeituraPotencia":0.0,"LeituraPressaoSP":0.0,"LeituraPressao":0.0,"Leitura":null,"Inicializado":false},"ScriptDeteccaoErvas":"weed_detector_oak-1_0.py","DadosLeitura":{"Momento":"0001-01-01T00:00:00","Conectado":false,"Mod_ID":null,"QualidadeWifi":0,"LatenciaLoop":0,"BicosPulverizadores":[],"BombasPressurizadoras":[],"SensoresFluxo":[],"SensoresMassa":[],"SensoresPressao":[]},"_MassaRef":0.8,"_MassaLeituraRef":40876.37,"_MassaLeituraExtra":1895800.0,"MassaReservatorio":0.0,"VolumeReservatorio":0.0,"PercentualReservatorio":0.0,"VolumeVazaoAferido":0.0,"_FluxoMlRef":102.0,"_FluxoPulsoRef":80.0,"VazaoFluxoMLpSInstantanea":0.0,"VazaoFluxoMLpSMedia":0.0,"VolumeVazaoML":0.0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0,"_PressaoVmin":0.0,"_PressaoVmax":4.5,"_PressaoMax":174.045,"PressaoLinha":0.0,"PressaoLinhaCalc":0.0,"PercentualErvasTerreno":0.0}

File diff suppressed because one or more lines are too long

View File

@ -4,12 +4,21 @@
"Arquivo": "model", "Arquivo": "model",
"Diretorio": "C:\\AgroBaseModels\\Ervas\\", "Diretorio": "C:\\AgroBaseModels\\Ervas\\",
"Extensao": ".blob", "Extensao": ".blob",
"Versao": "1_0", "Versao": "1_1",
"TipoArquivo": 1, "TipoArquivo": 1,
"ArquivoDownload": "weed_detector_model-1_0.blob" "ArquivoDownload": "weed_detector_model-1_1.blob"
}, },
{ {
"id": 2, "id": 2,
"Arquivo": "model",
"Diretorio": "C:\\AgroBaseModels\\Ervas\\",
"Extensao": ".json",
"Versao": "1_1",
"TipoArquivo": 1,
"ArquivoDownload": "weed_detector_model-1_1.json"
},
{
"id": 3,
"Diretorio": "C:\\AgroBaseModels\\Ruas\\", "Diretorio": "C:\\AgroBaseModels\\Ruas\\",
"Arquivo": "model", "Arquivo": "model",
"Extensao": ".pth", "Extensao": ".pth",
@ -22,7 +31,7 @@
"TipoArquivo": 0 "TipoArquivo": 0
}, },
{ {
"id": 3, "id": 4,
"Diretorio": "C:\\AgroBaseModels\\Ruas\\", "Diretorio": "C:\\AgroBaseModels\\Ruas\\",
"Arquivo": "labelmap", "Arquivo": "labelmap",
"Extensao": ".txt", "Extensao": ".txt",
@ -35,7 +44,7 @@
"TipoArquivo": 0 "TipoArquivo": 0
}, },
{ {
"id": 4, "id": 5,
"Diretorio": "Parametros/", "Diretorio": "Parametros/",
"Arquivo": "parametersAtu", "Arquivo": "parametersAtu",
"Extensao": ".par", "Extensao": ".par",
@ -48,7 +57,7 @@
"TipoArquivo": 2 "TipoArquivo": 2
}, },
{ {
"id": 5, "id": 6,
"Arquivo": "parametersMvd", "Arquivo": "parametersMvd",
"Diretorio": "Parametros/", "Diretorio": "Parametros/",
"Extensao": ".par", "Extensao": ".par",
@ -57,7 +66,7 @@
"ArquivoDownload": "parametersMvd-2_0.par" "ArquivoDownload": "parametersMvd-2_0.par"
}, },
{ {
"id": 6, "id": 7,
"Arquivo": "parametersSen", "Arquivo": "parametersSen",
"Diretorio": "Parametros/", "Diretorio": "Parametros/",
"Extensao": ".par", "Extensao": ".par",
@ -66,7 +75,7 @@
"ArquivoDownload": "parametersSen-1_2.par" "ArquivoDownload": "parametersSen-1_2.par"
}, },
{ {
"id": 7, "id": 8,
"Diretorio": "Parametros/", "Diretorio": "Parametros/",
"Arquivo": "parametersKnt", "Arquivo": "parametersKnt",
"Extensao": ".par", "Extensao": ".par",
@ -79,7 +88,7 @@
"TipoArquivo": 5 "TipoArquivo": 5
}, },
{ {
"id": 8, "id": 9,
"Diretorio": "Parametros/", "Diretorio": "Parametros/",
"Arquivo": "pinoutAtu", "Arquivo": "pinoutAtu",
"Extensao": ".pin", "Extensao": ".pin",
@ -92,7 +101,7 @@
"TipoArquivo": 6 "TipoArquivo": 6
}, },
{ {
"id": 9, "id": 10,
"Diretorio": "Parametros/", "Diretorio": "Parametros/",
"Arquivo": "pinoutSen", "Arquivo": "pinoutSen",
"Extensao": ".pin", "Extensao": ".pin",
@ -105,7 +114,7 @@
"TipoArquivo": 7 "TipoArquivo": 7
}, },
{ {
"id": 10, "id": 11,
"Diretorio": "Python\\Scripts\\", "Diretorio": "Python\\Scripts\\",
"Arquivo": "weed_detector_oak", "Arquivo": "weed_detector_oak",
"Extensao": ".py", "Extensao": ".py",
@ -118,7 +127,7 @@
"TipoArquivo": 9 "TipoArquivo": 9
}, },
{ {
"id": 11, "id": 12,
"Diretorio": "Python\\Scripts\\", "Diretorio": "Python\\Scripts\\",
"Arquivo": "green_detector", "Arquivo": "green_detector",
"Extensao": ".py", "Extensao": ".py",
@ -131,7 +140,7 @@
"TipoArquivo": 10 "TipoArquivo": 10
}, },
{ {
"id": 12, "id": 13,
"Diretorio": "Python\\Scripts\\", "Diretorio": "Python\\Scripts\\",
"Arquivo": "street_detector", "Arquivo": "street_detector",
"Extensao": ".py", "Extensao": ".py",
@ -144,7 +153,7 @@
"TipoArquivo": 8 "TipoArquivo": 8
}, },
{ {
"id": 13, "id": 14,
"Diretorio": "Python\\Scripts\\", "Diretorio": "Python\\Scripts\\",
"Arquivo": "map_load", "Arquivo": "map_load",
"Extensao": ".py", "Extensao": ".py",
@ -157,7 +166,7 @@
"TipoArquivo": 11 "TipoArquivo": 11
}, },
{ {
"id": 14, "id": 15,
"Diretorio": "Python\\Scripts\\", "Diretorio": "Python\\Scripts\\",
"Arquivo": "map_follow", "Arquivo": "map_follow",
"Extensao": ".py", "Extensao": ".py",
@ -170,7 +179,7 @@
"TipoArquivo": 12 "TipoArquivo": 12
}, },
{ {
"id": 15, "id": 16,
"Diretorio": "Python\\Scripts\\", "Diretorio": "Python\\Scripts\\",
"Arquivo": "gps_viewer", "Arquivo": "gps_viewer",
"Extensao": ".py", "Extensao": ".py",
@ -192,7 +201,7 @@
"ArquivoDownload": "modelo_3d-1_0.obj" "ArquivoDownload": "modelo_3d-1_0.obj"
}, },
{ {
"id": 17, "id": 18,
"Diretorio": "Python\\Output\\", "Diretorio": "Python\\Output\\",
"Arquivo": "modelo_3d", "Arquivo": "modelo_3d",
"Extensao": ".mtl", "Extensao": ".mtl",
@ -205,7 +214,7 @@
"TipoArquivo": 14 "TipoArquivo": 14
}, },
{ {
"id": 18, "id": 19,
"Diretorio": "Python\\Scripts\\", "Diretorio": "Python\\Scripts\\",
"Arquivo": "list_oak", "Arquivo": "list_oak",
"Extensao": ".py", "Extensao": ".py",

View File

@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"Id":"1","Name":"20_02_2025_12_56_23","Length":0.0,"Dist1":0.0,"Dist2":0.0},"geometry":{"id":null,"type":"LineString","coordinates":[[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0]]}}]} {"type":"FeatureCollection","features":[{"type":"Feature","properties":{"Id":"1","Name":"21_02_2025_13_48_00","Length":0.0,"Dist1":0.0,"Dist2":0.0},"geometry":{"id":null,"type":"LineString","coordinates":[[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0],[0.0,0.0]]}}]}

View File

@ -25,7 +25,7 @@
<meta name="viewport" content="width=device-width, <meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style> <style>
#map_d0dbf46f67163f94fe15580c6e5bb263 { #map_7d810bce8c49728809e1dfd9f77d8cb5 {
position: relative; position: relative;
width: 100.0%; width: 100.0%;
height: 100.0%; height: 100.0%;
@ -39,14 +39,14 @@
<body> <body>
<div class="folium-map" id="map_d0dbf46f67163f94fe15580c6e5bb263" ></div> <div class="folium-map" id="map_7d810bce8c49728809e1dfd9f77d8cb5" ></div>
</body> </body>
<script> <script>
var map_d0dbf46f67163f94fe15580c6e5bb263 = L.map( var map_7d810bce8c49728809e1dfd9f77d8cb5 = L.map(
"map_d0dbf46f67163f94fe15580c6e5bb263", "map_7d810bce8c49728809e1dfd9f77d8cb5",
{ {
center: [0.0, 0.0], center: [0.0, 0.0],
crs: L.CRS.EPSG3857, crs: L.CRS.EPSG3857,
@ -60,13 +60,13 @@
var tile_layer_da2b6f9ae365eadeb6f0473c9e2f5ecc = L.tileLayer( var tile_layer_216fc5661167ee0178b6878cb28fd987 = L.tileLayer(
"https://tile.openstreetmap.org/{z}/{x}/{y}.png", "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false} {"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
); );
tile_layer_da2b6f9ae365eadeb6f0473c9e2f5ecc.addTo(map_d0dbf46f67163f94fe15580c6e5bb263); tile_layer_216fc5661167ee0178b6878cb28fd987.addTo(map_7d810bce8c49728809e1dfd9f77d8cb5);
</script> </script>
@ -87,7 +87,7 @@
} }
trajeto_json_add({"features": []}); trajeto_json_add({"features": []});
trajeto_json.addTo(map_d0dbf46f67163f94fe15580c6e5bb263); trajeto_json.addTo(map_7d810bce8c49728809e1dfd9f77d8cb5);
function adicionarGeometria(novaGeometria) { function adicionarGeometria(novaGeometria) {
trajeto_json.addData(novaGeometria); trajeto_json.addData(novaGeometria);
@ -145,7 +145,7 @@
var marcadorDinamico = L.marker([0, 0], { var marcadorDinamico = L.marker([0, 0], {
icon: customIcon icon: customIcon
}).addTo(map_d0dbf46f67163f94fe15580c6e5bb263); }).addTo(map_7d810bce8c49728809e1dfd9f77d8cb5);
// Conectar ao broker MQTT // Conectar ao broker MQTT
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
@ -183,7 +183,7 @@
marcadorDinamico.setRotationAngle(angulo); marcadorDinamico.setRotationAngle(angulo);
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]); adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
map_d0dbf46f67163f94fe15580c6e5bb263.setView(novaPosicao, map_d0dbf46f67163f94fe15580c6e5bb263.getZoom()); map_7d810bce8c49728809e1dfd9f77d8cb5.setView(novaPosicao, map_7d810bce8c49728809e1dfd9f77d8cb5.getZoom());
}); });
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) { function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {

View File

@ -25,7 +25,7 @@
<meta name="viewport" content="width=device-width, <meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style> <style>
#map_719bc5033f2d7bbed16433f1688ca33e { #map_8ae520ade20d1e880decdae4c1b8c043 {
position: relative; position: relative;
width: 100.0%; width: 100.0%;
height: 100.0%; height: 100.0%;
@ -39,14 +39,14 @@
<body> <body>
<div class="folium-map" id="map_719bc5033f2d7bbed16433f1688ca33e" ></div> <div class="folium-map" id="map_8ae520ade20d1e880decdae4c1b8c043" ></div>
</body> </body>
<script> <script>
var map_719bc5033f2d7bbed16433f1688ca33e = L.map( var map_8ae520ade20d1e880decdae4c1b8c043 = L.map(
"map_719bc5033f2d7bbed16433f1688ca33e", "map_8ae520ade20d1e880decdae4c1b8c043",
{ {
center: [0.0, 0.0], center: [0.0, 0.0],
crs: L.CRS.EPSG3857, crs: L.CRS.EPSG3857,
@ -60,13 +60,13 @@
var tile_layer_585cdfdc9492eb1b05f6723f46c3d51d = L.tileLayer( var tile_layer_51104c3704cebc5a12257fbeda4557f1 = L.tileLayer(
"https://tile.openstreetmap.org/{z}/{x}/{y}.png", "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false} {"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
); );
tile_layer_585cdfdc9492eb1b05f6723f46c3d51d.addTo(map_719bc5033f2d7bbed16433f1688ca33e); tile_layer_51104c3704cebc5a12257fbeda4557f1.addTo(map_8ae520ade20d1e880decdae4c1b8c043);
@ -82,7 +82,7 @@
}*/ }*/
}); });
} }
function geo_json_10bf98f0b400ba97fe28246a3c7eff9a_onEachFeature(feature, layer) { function geo_json_db64117cc03e34aa9b3070e90c42dc6b_onEachFeature(feature, layer) {
layer.on({ layer.on({
click: function(e) { click: function(e) {
@ -118,20 +118,20 @@
}*/ }*/
}); });
}; };
var geo_json_10bf98f0b400ba97fe28246a3c7eff9a = L.geoJson(null, { var geo_json_db64117cc03e34aa9b3070e90c42dc6b = L.geoJson(null, {
onEachFeature: geo_json_10bf98f0b400ba97fe28246a3c7eff9a_onEachFeature, onEachFeature: geo_json_db64117cc03e34aa9b3070e90c42dc6b_onEachFeature,
}); });
function geo_json_10bf98f0b400ba97fe28246a3c7eff9a_add (data) { function geo_json_db64117cc03e34aa9b3070e90c42dc6b_add (data) {
geo_json_10bf98f0b400ba97fe28246a3c7eff9a geo_json_db64117cc03e34aa9b3070e90c42dc6b
.addData(data); .addData(data);
} }
geo_json_10bf98f0b400ba97fe28246a3c7eff9a_add({"features": [{"geometry": {"coordinates": [[0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], "id": null, "type": "LineString"}, "id": 0, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1", "Length": 0.0, "Name": "20_02_2025_12_56_23"}, "type": "Feature"}], "type": "FeatureCollection"}); geo_json_db64117cc03e34aa9b3070e90c42dc6b_add({"features": [{"geometry": {"coordinates": [[0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], "id": null, "type": "LineString"}, "id": 0, "properties": {"Dist1": 0.0, "Dist2": 0.0, "Id": "1", "Length": 0.0, "Name": "21_02_2025_13_48_00"}, "type": "Feature"}], "type": "FeatureCollection"});
geo_json_10bf98f0b400ba97fe28246a3c7eff9a.addTo(map_719bc5033f2d7bbed16433f1688ca33e); geo_json_db64117cc03e34aa9b3070e90c42dc6b.addTo(map_8ae520ade20d1e880decdae4c1b8c043);
</script> </script>
@ -152,7 +152,7 @@
} }
trajeto_json_add({"features": []}); trajeto_json_add({"features": []});
trajeto_json.addTo(map_719bc5033f2d7bbed16433f1688ca33e); trajeto_json.addTo(map_8ae520ade20d1e880decdae4c1b8c043);
function adicionarGeometria(novaGeometria) { function adicionarGeometria(novaGeometria) {
trajeto_json.addData(novaGeometria); trajeto_json.addData(novaGeometria);
@ -210,7 +210,7 @@
} }
trajeto_dinamico_json_add({"features": []}); trajeto_dinamico_json_add({"features": []});
trajeto_dinamico_json.addTo(map_719bc5033f2d7bbed16433f1688ca33e); trajeto_dinamico_json.addTo(map_8ae520ade20d1e880decdae4c1b8c043);
function adicionarGeometriaDinamica(novaGeometria) { function adicionarGeometriaDinamica(novaGeometria) {
trajeto_dinamico_json.addData(novaGeometria); trajeto_dinamico_json.addData(novaGeometria);
@ -263,9 +263,9 @@
var marcadorEquipamento = L.marker([0, 0], { var marcadorEquipamento = L.marker([0, 0], {
icon: customIcon icon: customIcon
}).addTo(map_719bc5033f2d7bbed16433f1688ca33e); }).addTo(map_8ae520ade20d1e880decdae4c1b8c043);
var marcadorBase = L.marker([0, 0], {}).addTo(map_719bc5033f2d7bbed16433f1688ca33e); var marcadorBase = L.marker([0, 0], {}).addTo(map_8ae520ade20d1e880decdae4c1b8c043);
var icon = L.AwesomeMarkers.icon( var icon = L.AwesomeMarkers.icon(
{"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "red", "prefix": "glyphicon"} {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "red", "prefix": "glyphicon"}
); );
@ -347,7 +347,7 @@
} }
if (foco) { if (foco) {
map_719bc5033f2d7bbed16433f1688ca33e.setView(novaPosicao, map_719bc5033f2d7bbed16433f1688ca33e.getZoom()); map_8ae520ade20d1e880decdae4c1b8c043.setView(novaPosicao, map_8ae520ade20d1e880decdae4c1b8c043.getZoom());
} }
} }
@ -364,7 +364,7 @@
function atualizarSelecaoRuas(selecionadas) { function atualizarSelecaoRuas(selecionadas) {
selecionadas = JSON.parse(selecionadas); selecionadas = JSON.parse(selecionadas);
RuasSelecionadas = Array.isArray(selecionadas) ? [...selecionadas] : []; RuasSelecionadas = Array.isArray(selecionadas) ? [...selecionadas] : [];
geo_json_10bf98f0b400ba97fe28246a3c7eff9a.eachLayer(function (layer) { geo_json_db64117cc03e34aa9b3070e90c42dc6b.eachLayer(function (layer) {
if (RuasSelecionadas.includes(parseInt(layer.feature.id))) { if (RuasSelecionadas.includes(parseInt(layer.feature.id))) {
layer.setStyle({ color: 'blue' }); layer.setStyle({ color: 'blue' });
} else { } else {

View File

@ -4,20 +4,52 @@ import sys
# 🔹 Desativar logs do DepthAI # 🔹 Desativar logs do DepthAI
os.environ["DEPTHAI_LEVEL"] = "ERROR" os.environ["DEPTHAI_LEVEL"] = "ERROR"
import depthai import depthai as dai
import json import json
devices = depthai.Device.getAllAvailableDevices() # Obtém todos os dispositivos conectados
devices = dai.Device.getAllAvailableDevices()
device_list = [] device_list = []
for idx, device in enumerate(devices): for idx, device_info in enumerate(devices):
device_info = { with dai.Device(device_info) as device:
"index": idx, try:
"id": device.mxid, memory_usage = device.getDdrMemoryUsage()
"model": device.name, memory_info = {
"usb_speed": str(device.protocol) "remaining": memory_usage.remaining,
} "total": memory_usage.total,
device_list.append(device_info) "used": memory_usage.used
}
except:
memory_info = None # Se houver erro, define como None
try:
temp = device.getChipTemperature()
temp_info = {
"css": temp.css,
"mss": temp.mss,
"upa": temp.upa,
"dss": temp.dss
}
except:
temp_info = None # Se houver erro, define como None
device_data = {
"index": idx,
"id": device_info.getMxId(), # ID do dispositivo
"name": device_info.name, # Nome do dispositivo
"state": device_info.state.name, # Estado do dispositivo
"usb_speed": str(device.getUsbSpeed().name) if hasattr(device, 'getUsbSpeed') else None, # Velocidade USB
"available_camera_sensors": [sensor.name for sensor in device.getConnectedCameras()], # Sensores de câmera disponíveis
"version": str(device.getDeviceInfo().protocol) if hasattr(device, 'getDeviceInfo') else None, # Versão do protocolo
"memory_usage": memory_info, # Uso de memória DDR
"temperature": temp_info, # Temperatura do chip
"bootloader_version": str(device.getBootloaderVersion()) if hasattr(device, 'getBootloaderVersion') else None, # Bootloader
"is_pipeline_running": device.isPipelineRunning() if hasattr(device, 'isPipelineRunning') else None # Pipeline rodando?
}
device_list.append(device_data)
# 🔹 Imprime apenas o JSON, sem logs extras # 🔹 Imprime apenas o JSON, sem logs extras
json_output = json.dumps(device_list, indent=4) json_output = json.dumps(device_list, indent=4)

View File

@ -31,11 +31,23 @@ app = Flask(__name__)
# Caminho do modelo convertido # Caminho do modelo convertido
blob_path = os.path.join(model_folder, f'model-{script_version}.blob') blob_path = os.path.join(model_folder, f'model-{script_version}.blob')
json_path = os.path.join(model_folder, f'model-{script_version}.json')
# Carregar configurações do modelo a partir do JSON
with open(json_path, 'r') as json_file:
model_config = json.load(json_file)
# Extraindo informações relevantes
input_size = model_config["nn_config"]["input_size"] # Exemplo: "416x416"
shape_width, shape_height = map(int, input_size.split("x")) # Convertendo para inteiros
iou_threshold = model_config["nn_config"]["NN_specific_metadata"]["iou_threshold"]
conf_threshold = model_config["nn_config"]["NN_specific_metadata"]["confidence_threshold"]
labelMap = model_config["mappings"]["labels"] # Lista de classes do modelo
width, height = 1280, 720
def detect_oak(camera_index): def detect_oak(camera_index):
width, height, model_resolution = 1280, 720, 640
labelMap = ['chenopodio', 'grama-azul', 'tiririca', 'erva-daninha', 'videira', 'mostarda-preta', 'milho', 'amaranta', 'farinha-seca', 'guanxuma']
pipeline = dai.Pipeline() pipeline = dai.Pipeline()
# Listar todas as câmeras conectadas # Listar todas as câmeras conectadas
@ -58,36 +70,41 @@ def detect_oak(camera_index):
cam.setVideoSize(width, height) cam.setVideoSize(width, height)
cam.setInterleaved(False) cam.setInterleaved(False)
cam.setColorOrder(dai.ColorCameraProperties.ColorOrder.BGR) cam.setColorOrder(dai.ColorCameraProperties.ColorOrder.BGR)
cam.setFps(35) # FPS aumentado cam.setFps(30) # FPS aumentado
cam.setIspScale(2, 3) # Reduz carga no pipeline cam.setIspScale(2, 3) # Reduz carga no pipeline
# Criando um nó de manipulação de imagem otimizado # Criando um nó de manipulação de imagem otimizado
manip = pipeline.create(dai.node.ImageManip) manip = pipeline.create(dai.node.ImageManip)
manip.initialConfig.setResize(model_resolution, model_resolution) manip.initialConfig.setResize(shape_width, shape_height)
manip.initialConfig.setKeepAspectRatio(True) manip.initialConfig.setKeepAspectRatio(False)
manip.initialConfig.setFrameType(dai.RawImgFrame.Type.RGB888p) # Força formato RGB correto manip.initialConfig.setFrameType(dai.RawImgFrame.Type.RGB888p) # Força formato RGB correto
#manip.initialConfig.setHorizontalFlip(True)
#manip.initialConfig.setVerticalFlip(True)
manip.setMaxOutputFrameSize(1228800) manip.setMaxOutputFrameSize(1228800)
cam.video.link(manip.inputImage) cam.video.link(manip.inputImage)
# Criando um nó de inferência YOLO otimizado # Criando um nó de inferência YOLO otimizado
nn = pipeline.create(dai.node.YoloDetectionNetwork) nn = pipeline.create(dai.node.YoloDetectionNetwork)
nn.setBlobPath(blob_path) nn.setBlobPath(blob_path)
nn.setConfidenceThreshold(0.25) nn.setConfidenceThreshold(conf_threshold)
nn.setNumClasses(len(labelMap)) nn.setNumClasses(len(labelMap))
nn.setCoordinateSize(4) nn.setCoordinateSize(4)
nn.setIouThreshold(0.45) nn.setIouThreshold(iou_threshold)
# 🔹 Define âncoras e máscaras corretamente
nn.setAnchors([ # 🔹 Define âncoras e máscaras corretamente
12, 16, 19, 36, 40, 28, #nn.setAnchors([
36, 75, 76, 55, 72, 146, # 12, 16, 19, 36, 40, 28,
142, 110, 192, 243, 459, 401 # 36, 75, 76, 55, 72, 146,
]) # 142, 110, 192, 243, 459, 401
#])
#nn.setAnchorMasks({
# "side52": [0, 1, 2],
# "side26": [3, 4, 5],
# "side13": [6, 7, 8]
#})
nn.setAnchorMasks({
"side52": [0, 1, 2],
"side26": [3, 4, 5],
"side13": [6, 7, 8]
})
nn.setNumInferenceThreads(2) # Usa 2 threads para inferência nn.setNumInferenceThreads(2) # Usa 2 threads para inferência
nn.input.setBlocking(False) # Não bloqueia a entrada de frames nn.input.setBlocking(False) # Não bloqueia a entrada de frames
#nn.setReusePreviousInferenceResults(True) # Reutiliza inferências para não travar o pipeline #nn.setReusePreviousInferenceResults(True) # Reutiliza inferências para não travar o pipeline
@ -110,7 +127,11 @@ def detect_oak(camera_index):
readings = [] readings = []
while True: while True:
frame = video_queue.get().getCvFrame() frame_data = video_queue.tryGet() # 🔹 Usa tryGet() para evitar bloqueios
if frame_data is None:
continue # Se não houver um frame disponível, pula a iteração
frame = frame_data.getCvFrame()
in_det = detections_queue.get() in_det = detections_queue.get()
detections = in_det.detections detections = in_det.detections
@ -142,7 +163,42 @@ def detect_oak(camera_index):
global json_data global json_data
timestamp = time.time() timestamp = time.time()
json_data = {'timestamp': timestamp, 'x_max': width, 'y_max': height, 'objetos': current_readings}
try:
memory_usage = device.getDdrMemoryUsage()
memory_info = {
"remaining": memory_usage.remaining,
"total": memory_usage.total,
"used": memory_usage.used
}
except:
memory_info = None # Se houver erro, define como None
try:
temp = device.getChipTemperature()
temp_info = {
"css": temp.css,
"mss": temp.mss,
"upa": temp.upa,
"dss": temp.dss
}
except:
temp_info = None # Se houver erro, define como None
device_data = {
"id": selected_device_info.getMxId(), # ID do dispositivo
"name": selected_device_info.name, # Nome do dispositivo
"state": selected_device_info.state.name, # Estado do dispositivo
"usb_speed": str(device.getUsbSpeed().name) if hasattr(device, 'getUsbSpeed') else None, # Velocidade USB
"available_camera_sensors": [sensor.name for sensor in device.getConnectedCameras()], # Sensores de câmera disponíveis
"version": str(device.getDeviceInfo().protocol) if hasattr(device, 'getDeviceInfo') else None, # Versão do protocolo
"memory_usage": memory_info, # Uso de memória DDR
"temperature": temp_info, # Temperatura do chip
"bootloader_version": str(device.getBootloaderVersion()) if hasattr(device, 'getBootloaderVersion') else None, # Bootloader
"is_pipeline_running": device.isPipelineRunning() if hasattr(device, 'isPipelineRunning') else None # Pipeline rodando?
}
json_data = {'timestamp': timestamp, 'x_max': width, 'y_max': height, 'objetos': current_readings, 'device_data': device_data}
print(json_data) print(json_data)
readings.append(json_data) readings.append(json_data)
@ -167,6 +223,8 @@ def run_flask_server():
@app.route('/' + url, methods=['GET']) @app.route('/' + url, methods=['GET'])
def video_feed(): def video_feed():
conf_threshold = float(request.args.get('conf_threshold'))
nms_threshold = float(request.args.get('nms_threshold'))
camera_index = int(request.args.get('camera_index')) camera_index = int(request.args.get('camera_index'))
return Response(detect_oak(camera_index), mimetype='multipart/x-mixed-replace; boundary=frame') return Response(detect_oak(camera_index), mimetype='multipart/x-mixed-replace; boundary=frame')

View File

@ -0,0 +1,132 @@
import depthai as dai
import cv2
import numpy as np
import time
import json
import sys
import threading
import paho.mqtt.client as mqtt
import uuid
from flask import Flask, Response
# 🔹 Configurações MQTT
mqtt_client = mqtt.Client(f"client_oak_d_lite_{uuid.uuid4()}")
mqtt_client.connect("localhost", port=1883)
# 🔹 Parâmetros de entrada
output_folder = 'Python/Output/'
mqtt_topic = sys.argv[1] # Tópico MQTT para envio dos dados de profundidade
porta = int(sys.argv[2]) # Porta do Flask
url = sys.argv[3] # URL do vídeo
mostrar_linhas = sys.argv[4] == "1" # Se deve exibir sobreposições na imagem
# 🔹 Flask App
app = Flask(__name__)
# 🔹 Criando o pipeline
pipeline = dai.Pipeline()
# 📷 Câmera RGB
cam_rgb = pipeline.create(dai.node.ColorCamera)
cam_rgb.setPreviewSize(1280, 720)
cam_rgb.setBoardSocket(dai.CameraBoardSocket.RGB)
cam_rgb.setInterleaved(False)
# Criar XLinkOut para saída RGB
xout_rgb = pipeline.create(dai.node.XLinkOut)
xout_rgb.setStreamName("rgb")
cam_rgb.preview.link(xout_rgb.input)
# 🔹 Câmera de Profundidade
mono_left = pipeline.create(dai.node.MonoCamera)
mono_right = pipeline.create(dai.node.MonoCamera)
stereo = pipeline.create(dai.node.StereoDepth)
mono_left.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
mono_right.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
mono_left.setBoardSocket(dai.CameraBoardSocket.LEFT)
mono_right.setBoardSocket(dai.CameraBoardSocket.RIGHT)
# Configuração do StereoDepth
stereo.setDefaultProfilePreset(dai.node.StereoDepth.PresetMode.HIGH_DENSITY)
stereo.setLeftRightCheck(True)
stereo.setSubpixel(True)
mono_left.out.link(stereo.left)
mono_right.out.link(stereo.right)
# Criar XLinkOut para profundidade
xout_depth = pipeline.create(dai.node.XLinkOut)
xout_depth.setStreamName("depth")
stereo.depth.link(xout_depth.input)
# 🔹 Função para capturar e processar os frames
def process_frames():
with dai.Device(pipeline) as device:
rgb_queue = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
depth_queue = device.getOutputQueue(name="depth", maxSize=4, blocking=False)
while True:
timestamp = time.time()
# 📷 Captura RGB
rgb_frame = rgb_queue.get().getCvFrame()
# 📏 Captura Profundidade
depth_frame = depth_queue.get().getFrame()
# Normaliza a profundidade para visualização (mapa de calor)
depth_visual = cv2.normalize(depth_frame, None, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8U)
depth_visual = cv2.applyColorMap(depth_visual, cv2.COLORMAP_JET)
# 📡 Enviar dados via MQTT (Apenas a matriz de profundidade reduzida)
depth_data = depth_frame.tolist() # Converte a matriz para lista JSON
json_data = {
'timestamp': timestamp,
'depth_data': depth_data
}
mqtt_client.publish(mqtt_topic, json.dumps(json_data).encode('utf-8'))
# 🔹 Função para enviar vídeo via Flask
def generate_video():
with dai.Device(pipeline) as device:
rgb_queue = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
depth_queue = device.getOutputQueue(name="depth", maxSize=4, blocking=False)
while True:
frame_data = rgb_queue.get()
if frame_data is None:
continue
timestamp = time.time()
# 📏 Captura Profundidade
depth_frame = depth_queue.get().getFrame()
# Normaliza a profundidade para visualização (mapa de calor)
depth_visual = cv2.normalize(depth_frame, None, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8U)
depth_visual = cv2.applyColorMap(depth_visual, cv2.COLORMAP_JET)
# 📡 Enviar dados via MQTT (Apenas a matriz de profundidade reduzida)
depth_data = depth_frame.tolist() # Converte a matriz para lista JSON
json_data = {
'timestamp': timestamp,
'depth_data': depth_data
}
mqtt_client.publish(mqtt_topic, json.dumps(json_data).encode('utf-8'))
frame = frame_data.getCvFrame()
ret, buffer = cv2.imencode('.jpg', frame)
frame = buffer.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/' + url, methods=['GET'])
def video_feed():
return Response(generate_video(), mimetype='multipart/x-mixed-replace; boundary=frame')
# 🔹 Rodar Flask e processamento em threads separadas
if __name__ == '__main__':
app.run(host='0.0.0.0', port=porta, threaded=True, debug=False)

View File

@ -0,0 +1,23 @@
import numpy as np
# Lista de timestamps extraídos dos logs
timestamps = [
1740141846.5032837, 1740141846.5219097, 1740141846.6311488, 1740141846.6716733, 1740141846.6918433,
1740141846.79832, 1740141846.8394804, 1740141846.8599749, 1740141846.9667242, 1740141847.0082366,
1740141847.0282125, 1740141847.1342206, 1740141847.176188, 1740141847.1952803, 1740141847.3016286,
1740141847.3431587, 1740141847.3631606, 1740141847.4687777, 1740141847.5097976, 1740141847.5298164,
1740141847.6366794, 1740141847.687985, 1740141847.7069635, 1740141847.803649, 1740141847.8451722,
1740141847.865326, 1740141847.9729707, 1740141848.0150697, 1740141848.0360775, 1740141848.1428683,
1740141848.182964, 1740141848.202432, 1740141848.31, 1740141848.3530478, 1740141848.373526,
1740141848.478831, 1740141848.5203228, 1740141848.5403388, 1740141848.6465094, 1740141848.688516,
1740141848.7095163
]
# Calcular diferenças entre timestamps consecutivos
time_diffs = np.diff(timestamps)
# Calcular FPS médio
fps_medio = 1 / np.mean(time_diffs)
fps_medio
print(f"FPS médio: {fps_medio:.2f}")

View File

@ -1,17 +1,57 @@
import depthai import os
import sys
# 🔹 Desativar logs do DepthAI
os.environ["DEPTHAI_LEVEL"] = "ERROR"
import depthai as dai
import json import json
devices = depthai.Device.getAllAvailableDevices() # Obtém todos os dispositivos conectados
devices = dai.Device.getAllAvailableDevices()
device_list = [] device_list = []
for idx, device in enumerate(devices): for idx, device_info in enumerate(devices):
device_info = { with dai.Device(device_info) as device:
"index": idx, try:
"id": device.mxid, # ID único da câmera memory_usage = device.getDdrMemoryUsage()
"model": device.name, # Nome correto do modelo memory_info = {
"usb_speed": str(device.protocol) # Informação da conexão USB "remaining": memory_usage.remaining,
} "total": memory_usage.total,
device_list.append(device_info) "used": memory_usage.used
}
except:
memory_info = None # Se houver erro, define como None
# Retorna a lista em formato JSON try:
print(json.dumps(device_list, indent=4)) temp = device.getChipTemperature()
temp_info = {
"css": temp.css,
"mss": temp.mss,
"upa": temp.upa,
"dss": temp.dss
}
except:
temp_info = None # Se houver erro, define como None
device_data = {
"index": idx,
"id": device_info.getMxId(), # ID do dispositivo
"name": device_info.name, # Nome do dispositivo
"state": device_info.state.name, # Estado do dispositivo
"usb_speed": str(device.getUsbSpeed().name) if hasattr(device, 'getUsbSpeed') else None, # Velocidade USB
"available_camera_sensors": [sensor.name for sensor in device.getConnectedCameras()], # Sensores de câmera disponíveis
"version": str(device.getDeviceInfo().protocol) if hasattr(device, 'getDeviceInfo') else None, # Versão do protocolo
"memory_usage": memory_info, # Uso de memória DDR
"temperature": temp_info, # Temperatura do chip
"bootloader_version": str(device.getBootloaderVersion()) if hasattr(device, 'getBootloaderVersion') else None, # Bootloader
"is_pipeline_running": device.isPipelineRunning() if hasattr(device, 'isPipelineRunning') else None # Pipeline rodando?
}
device_list.append(device_data)
# 🔹 Imprime apenas o JSON, sem logs extras
json_output = json.dumps(device_list, indent=4)
sys.stdout.write(json_output)
sys.stdout.flush()