03_colorDetection.py 792 B

12345678910111213141516
  1. #!/usr/bin/env python
  2. #version : 2023.12.31
  3. #language : ch
  4. from maix import display
  5. from maix import image
  6. from maix import camera
  7. camera.camera.config(size=(320,240))
  8. image.load_freetype("/root/preset/fonts/SourceHanSansCN-Regular.otf")
  9. while True:
  10. canvas = camera.capture()
  11. RGB = canvas.get_blob_color((154, 114, 10, 10), 0, 0)
  12. canvas.draw_rectangle(154,114, 164,124, color=(255,0,0), thickness=1)
  13. canvas.draw_rectangle(0,0, 319,20, color=((int(RGB[0])),(int(RGB[1])),(int(RGB[2]))), thickness=-1)
  14. canvas.draw_string(120,0, (''.join([str(x) for x in ["(", int(RGB[0]), ",", int(RGB[1]), ",", int(RGB[2]), ")"]])), scale = 1, color = ((255 - int(RGB[0])),(255 - int(RGB[1])),(255 - int(RGB[2]))), thickness = 1)
  15. display.show(canvas)