Commit 7d89645a authored by Ivan Tyagov's avatar Ivan Tyagov

Update only if it makes sense.

parent f23927cb
...@@ -161,10 +161,11 @@ async def main(): ...@@ -161,10 +161,11 @@ async def main():
print("\tDetected area (px)=%.2f, result=%d, shape changes=%d" %(area, result, shape_change_counter)) print("\tDetected area (px)=%.2f, result=%d, shape changes=%d" %(area, result, shape_change_counter))
# update list for last X results (FILO) # update list for last X results (FILO)
result_stack.append(result) if current_shape != result:
current_shape = result result_stack.append(result)
shape_change_counter += 1 current_shape = result
await myvar.write_value(result) shape_change_counter += 1
await myvar.write_value(result)
# break current countour detection loop as in this example we care # break current countour detection loop as in this example we care
# for first detected SHAPE, we do not expect more shapes # for first detected SHAPE, we do not expect more shapes
...@@ -173,9 +174,10 @@ async def main(): ...@@ -173,9 +174,10 @@ async def main():
if not contour_detected: if not contour_detected:
# no countours actually detected thus update OPC UA server's node attribute # no countours actually detected thus update OPC UA server's node attribute
result = 0.0 result = 0.0
result_stack.append(result) if current_shape != result:
shape_change_counter += 1 result_stack.append(result)
await myvar.write_value(result) shape_change_counter += 1
await myvar.write_value(result)
current_shape = result current_shape = result
print("\tNo shape detected, result=%d, shape changes=%d" %(result, shape_change_counter)) print("\tNo shape detected, result=%d, shape changes=%d" %(result, shape_change_counter))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment