detection no-tflite ok

This commit is contained in:
stres1 2022-07-29 18:18:29 +02:00
parent a0d1703e8f
commit 66fb6f3929
8 changed files with 178 additions and 34 deletions

View File

@ -9,9 +9,9 @@ exposure_time: 10000
; vertical_crop_resolution: 2048
; rotate_90_clockwise times: 0
; auto_white_balance: off
balance_red: 1.66
balance_red: 1.85
balance_green: 1.0
balance_blue: 1.12
balance_blue: 1.5
[vision_saver]
time_format: %Y-%m-%d_%H-%M-%S
@ -43,7 +43,7 @@ port: COM1
baudrate: 9600
[vision]
detection_threshold: 0.75
neural_network: hs3-20000
detection_threshold: 0.5
neural_network: hs5-20000
; recipes_path: ./config/vision_test_recipes

View File

@ -22,7 +22,7 @@ instruction: CONTROLLARE PRESENZA TERMORESTRINGENTE
[markers]
[zones]
p1: 800,850 300,100 hs-ok # HEATSINK PRESENT
p1: 1000,500 800,800 hs-ok # HEATSINK PRESENT
[labels]
p1: 500,600 120 0xffffffff 0xff000000 4 TERMORESTRINGENTE
p1: 660,1200 120 0xffffffff 0xff000000 4 TERMORESTRINGENTE

View File

@ -1,4 +1,4 @@
#!/bin/bash -e
cd "$(dirname "$0")"
source "./venv/bin/activate" || source "./venv/Scripts/activate" || :
python -O "./src/main.py"
python -O "./src/main.py" --no-edgetpu --no-tflite

View File

@ -24,6 +24,8 @@ class NeoPixels(Component):
parity=self.parity,
bytesize=self.bytesize,
)
time.sleep(5)
self.set_all_pixel_color("#000000")
def config_changed(self):
self.port = self.config[self.name]["port"]
@ -40,7 +42,7 @@ class NeoPixels(Component):
try:
self.conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n")
response = self.conn.readline()
if response != "ok\n":
if response != b"ok\n":
self.log.error(response.strip())
# conn.close()
except serial.serialutil.SerialException:

View File

@ -1,3 +1,4 @@
import time
from ctypes import c_uint32
import serial
@ -13,7 +14,8 @@ conn = serial.Serial(
xonxoff=False
)
pixel = C_UINT32_MAX
color = "#ff00ff"
time.sleep(5)
color = "#000000"
conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n")
response = conn.readline()
print(response)

View File

@ -283,6 +283,9 @@ class Test(Widget):
# LABEL PRINT
datamatrix= archived.recipe.part_number+ archived.time.strftime("%m%y")+f"{archived.id:0>5}"
dt_label=archived.time.strftime("%d/%m/%Y %H:%M:%S")
pmax = self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("test_pressure", "-")
pmin=self.data.get("leak", [{}, {}])[0].get("results", {}).get("data", {}).get("Running test: pressure at the end of settling", "-")
leak=self.data.get("leak", [{}, {}])[0].get("results", {}).get("data", {}).get("Running test: measured leak", "-")
context = {
"DATAMATRIX": datamatrix,
"DATAMATRIX_TEXT": datamatrix,
@ -291,9 +294,9 @@ class Test(Widget):
"SHIFT": str(get_shift(archived.time)),
"STATION": str(self.machine_id),
"OPERATOR": str(Users.get_session().user.username),
"PMAX": str(self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("test_pressure", "-")),
"PMIN": str(self.data.get("leak", [{}, {}])[0].get("results", {}).get("data", {}).get("Running test: pressure at the end of settling", "-")),
"LEAK": str(self.data.get("leak", [{}, {}])[0].get("results", {}).get("data", {}).get("Running test: measured leak", "-")),
"PMAX": f"{pmax:.3f}",
"PMIN": f"{pmin:.3f}",
"LEAK": f"{leak:.3f}",
"TFILL": str(self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("filling_time", "-")),
"TSTAB": str(self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("settling_time", "-")),
"TTEST": str(self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("test_time", "-")),

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>854</width>
<width>980</width>
<height>704</height>
</rect>
</property>
@ -31,9 +31,9 @@
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
@ -48,9 +48,9 @@
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
@ -65,9 +65,9 @@
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
@ -82,9 +82,9 @@
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
@ -97,6 +97,24 @@
</item>
<item row="2" column="1">
<widget class="QLabel" name="leak_l">
<property name="maximumSize">
<size>
<width>130</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 1px solid black;
</string>
</property>
<property name="text">
<string>-</string>
</property>
@ -104,6 +122,24 @@
</item>
<item row="1" column="1">
<widget class="QLabel" name="circuit_pressure_l">
<property name="maximumSize">
<size>
<width>130</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 1px solid black;
</string>
</property>
<property name="text">
<string>-</string>
</property>
@ -113,9 +149,9 @@
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
@ -141,6 +177,24 @@
</item>
<item row="3" column="1">
<widget class="QLabel" name="regulated_pressure_l">
<property name="maximumSize">
<size>
<width>130</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 1px solid black;
</string>
</property>
<property name="text">
<string>-</string>
</property>
@ -150,9 +204,9 @@
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
@ -165,6 +219,13 @@
</item>
<item row="3" column="2">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>mbar</string>
</property>
@ -172,6 +233,13 @@
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>mbar</string>
</property>
@ -179,6 +247,13 @@
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>mbar</string>
</property>
@ -188,11 +263,16 @@
<widget class="QLabel" name="test_phase_l">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 1px solid black;
</string>
</property>
<property name="text">
<string>-</string>
</property>
@ -200,6 +280,18 @@
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="test_type_l">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 1px solid black;
</string>
</property>
<property name="text">
<string>-</string>
</property>
@ -207,6 +299,18 @@
</item>
<item row="5" column="1" colspan="2">
<widget class="QLabel" name="sequence_index_l">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 1px solid black;
</string>
</property>
<property name="text">
<string>-</string>
</property>

View File

@ -1,9 +1,18 @@
import os
import sys
from datetime import datetime
import cv2
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtGui import QImage, QPixmap
from ui.test_test import Test_Test
TMP_DIR = "tmp"
ARCHIVE_DIR = "data/vision_saves"
INFERENCE_INPUT_W = 256
INFERENCE_INPUT_H = 256
class Test_Vision(Test_Test):
request_frame = pyqtSignal()
@ -27,6 +36,7 @@ class Test_Vision(Test_Test):
self.components["vision"].resume()
self.components["galaxy_camera"].resume()
self.request_frame.emit() # request first frame
self.save_b.clicked.connect(lambda: self.save_frame_all(position="tmp"))
def stop(self):
# disable camera-vision loop
@ -98,3 +108,26 @@ class Test_Vision(Test_Test):
self.last.pop("render", None)
super().emit_ko()
self.components["neo_pixels"].set_all_pixel_color("#000000")
def save_frame_detection(self, position=None, date=None):
if date is None:
date = datetime.now()
if position == "archive":
save_dir = ARCHIVE_DIR
elif position == "tmp":
save_dir = TMP_DIR
elif position is None:
save_dir = self.config["image saver"]["location"]
else:
save_dir = position
save_dir += "/img_archive"
save_dir += f"/{date.strftime('%Y')}/{date.strftime('%m')}"
self.remove_older_images_if_needed()
if not os.path.exists(save_dir):
os.makedirs(save_dir, exist_ok=True)
filename = f"{save_dir}/{date.strftime('%Y-%m-%d_%H_%M_%S')}_{self.config['image saver']['suffix']}.png"
print(f"saving {filename}")
image_np_bgr = cv2.cvtColor(self.detection_image, cv2.COLOR_RGB2BGR)
cv2.imwrite(filename, image_np_bgr)
return filename