Skip to content
Snippets Groups Projects
Commit a608d280 authored by ft-Demo's avatar ft-Demo
Browse files

commit by robo pro coding

parent 7d1e03fe
No related branches found
No related tags found
No related merge requests found
......@@ -59,7 +59,7 @@ TXTWindow {
}
TXTLabel {
id: version_label
text: "Sorting Line AI: Version 2023/01/17"
text: "Sorting Line AI: Version 2023/01/20"
font.pixelSize: 16
elide: Text.ElideRight
x: 20
......
<xml type="display" version="2"><item id="33" class="TXTLabel"><name>img_label</name><text/><geometry><x>20</x><y>20</y><width>200</width><height>150</height></geometry></item><item id="20" class="StatusIndicator"><name>red</name><color>#EC1600</color><active>false</active><geometry><x>70</x><y>195</y><width>35</width><height>35</height></geometry></item><item id="21" class="StatusIndicator"><name>white</name><color>#FFFFFF</color><active>false</active><geometry><x>0</x><y>195</y><width>35</width><height>35</height></geometry></item><item id="22" class="StatusIndicator"><name>blue</name><color>#005693</color><active>false</active><geometry><x>135</x><y>195</y><width>35</width><height>35</height></geometry></item><item id="23" class="StatusIndicator"><name>fail</name><color>#E7AE13</color><active>false</active><geometry><x>205</x><y>195</y><width>35</width><height>35</height></geometry></item><item id="24" class="TXTLabel"><name>version_label</name><text>Sorting Line AI: Version 2023/01/17</text><geometry><x>20</x><y>0</y><width>200</width><height>20</height></geometry></item><item id="28" class="TXTLabel"><name>part_pass_fail</name><text>&lt;font&gt;Webadress loading...&lt;/font&gt;</text><geometry><x>20</x><y>170</y><width>200</width><height>20</height></geometry></item></xml>
\ No newline at end of file
<xml type="display" version="2"><item id="33" class="TXTLabel"><name>img_label</name><text/><geometry><x>20</x><y>20</y><width>200</width><height>150</height></geometry></item><item id="20" class="StatusIndicator"><name>red</name><color>#EC1600</color><active>false</active><geometry><x>70</x><y>195</y><width>35</width><height>35</height></geometry></item><item id="21" class="StatusIndicator"><name>white</name><color>#FFFFFF</color><active>false</active><geometry><x>0</x><y>195</y><width>35</width><height>35</height></geometry></item><item id="22" class="StatusIndicator"><name>blue</name><color>#005693</color><active>false</active><geometry><x>135</x><y>195</y><width>35</width><height>35</height></geometry></item><item id="23" class="StatusIndicator"><name>fail</name><color>#E7AE13</color><active>false</active><geometry><x>205</x><y>195</y><width>35</width><height>35</height></geometry></item><item id="24" class="TXTLabel"><name>version_label</name><text>Sorting Line AI: Version 2023/01/20</text><geometry><x>20</x><y>0</y><width>200</width><height>20</height></geometry></item><item id="28" class="TXTLabel"><name>part_pass_fail</name><text>&lt;font&gt;Webadress loading...&lt;/font&gt;</text><geometry><x>20</x><y>170</y><width>200</width><height>20</height></geometry></item></xml>
\ No newline at end of file
source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -32,14 +32,15 @@ pos = None
frame = None
ts_process0 = None
detector = None
ts_process1 = None
result = None
ts_proces = None
ts_process = None
key = None
log = None
def MakePictureRunKiReturnFoundPart():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, result, ts_proces, key, log
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key, log
reset_inteface()
TXT_SLD_M_O4_led.set_brightness(int(512))
time.sleep(0.2)
......@@ -62,9 +63,10 @@ def MakePictureRunKiReturnFoundPart():
TXT_SLD_M_M1_encodermotor.set_distance(int(200))
ts_process0 = (time.time() * 1000)
detector = ObjectDetector('/opt/ft/workspaces/machine-learning/object-detection/sorting_line/model.tflite', '/opt/ft/workspaces/machine-learning/object-detection/sorting_line/labels.txt')
ts_process1 = (time.time() * 1000)
result = detector.process_image(frame)
ts_proces = (time.time() * 1000)
print('processing time: {:.0f} ms'.format(ts_proces - ts_process0))
ts_process = (time.time() * 1000)
print('processing time: {:.0f} ms {:.0f} ms'.format(ts_process1 - ts_process0, ts_process - ts_process1))
color = get_color()
TXT_SLD_M_O4_led.set_brightness(int(0))
print(result)
......@@ -74,7 +76,7 @@ def MakePictureRunKiReturnFoundPart():
key = result[0]['label']
if True:
log = open('/opt/ft/workspaces/log.txt', 'a', encoding='utf8')
log.write('{} ms: {:.0f} key: {} prob: {:.2f} color: {}'.format(timestamp(), ts_proces - ts_process0, key, prob, color) + '\n')
log.write('{} ms: {:.0f} {:.0f} key: {} prob: {:.2f} color: {}'.format(timestamp(), ts_process1 - ts_process0, ts_process - ts_process1, key, prob, color) + '\n')
log.close()
keytext = ''
if key == 'CRACK':
......@@ -120,7 +122,7 @@ def MakePictureRunKiReturnFoundPart():
def reset_inteface():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, result, ts_proces, key, log
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key, log
display.set_attr("part_pass_fail.text", str(containInHTML('i', 'Not analysed yet')))
display.set_attr("red.active", str(False).lower())
display.set_attr("white.active", str(False).lower())
......@@ -129,12 +131,12 @@ def reset_inteface():
def containInHTML(tag, value):
global num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, result, ts_proces, key, log
global num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key, log
return ''.join([str(x) for x in ['<', tag, '>', value, '</', tag, '>']])
def get_color():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, result, ts_proces, key, log
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key, log
if hue >= 85 and hue < 130 and sat >= 40:
color = 3
elif (hue >= 130 and hue <= 180 or hue >= 0 and hue < 15) and sat >= 40:
......@@ -145,13 +147,13 @@ def get_color():
def timestamp():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, result, ts_proces, key, log
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key, log
ts = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
return ts
def saveFileandPublish():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, result, ts_proces, key, log
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key, log
filename = '/opt/ft/workspaces/last-image.png'
if(pos != ""):
image = cv2.rectangle(frame, (pos[0], pos[1]), (pos[2], pos[3]), (180,105,0), 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment