久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 4064|回復(fù): 0
收起左側(cè)

python openmv色塊跟隨源程序

[復(fù)制鏈接]
ID:255401 發(fā)表于 2019-8-5 19:55 | 顯示全部樓層 |閱讀模式
openmv色塊跟隨,串口打印出色塊區(qū)域的中點(diǎn)坐標(biāo)
利用openmv實(shí)現(xiàn)色塊追隨,在程序中調(diào)整閾值即可實(shí)現(xiàn)任意顏色的跟隨
,想要提升幀率可以把圖像格式改為QQVGA

源程序如下:
  1. # Blob Detection and uart transport
  2. import sensor, image, time
  3. from pyb import UART
  4. import json
  5. # For color tracking to work really well you should ideally be in a very, very,
  6. # very, controlled enviroment where the lighting is constant...
  7. yellow_threshold   = (31, 88, 40, 127, -25, 122)
  8. # You may need to tweak the above settings for tracking green things...
  9. # Select an area in the Framebuffer to copy the color settings.

  10. sensor.reset() # Initialize the camera sensor.
  11. sensor.set_pixformat(sensor.RGB565) # use RGB565.
  12. sensor.set_framesize(sensor.QVGA) # use QQVGA for speed.
  13. sensor.skip_frames(10) # Let new settings take affect.
  14. sensor.set_auto_whitebal(False) # turn this off.
  15. clock = time.clock() # Tracks FPS.

  16. uart = UART(3, 115200)
  17. def find_max(blobs):
  18.     max_size=0
  19.     for blob in blobs:
  20.         if blob.pixels() > max_size:
  21.             max_blob=blob
  22.             max_size = blob.pixels()
  23.     return max_blob

  24. while(True):
  25.     img = sensor.snapshot() # Take a picture and return the image.

  26.     blobs = img.find_blobs([yellow_threshold])
  27.     if blobs:
  28.         max_blob=find_max(blobs)
  29.         print('sum :', len(blobs))
  30.         img.draw_rectangle(max_blob.rect())
  31.         img.draw_cross(max_blob.cx(), max_blob.cy())

  32.         output_str="%.3d,%.3d" % (max_blob.cx(),max_blob.cy()) #方式1
  33.         #output_str=json.dumps([max_blob.cx(),max_blob.cy()]) #方式2
  34.         print('you send:',output_str)
  35.         uart.write(output_str+'\r\n')
  36.     else:
  37.         print('not found!')
復(fù)制代碼

以上資料51hei提供下載:
uart_red.zip (1.16 KB, 下載次數(shù): 25)


回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 亚洲精品第一国产综合野 | 亚洲一区在线免费观看 | 99热都是精品| 国产福利资源 | a视频在线| 亚洲精品99999 | 久草在线中文888 | 天天干天天爱天天爽 | 日韩一区二区三区在线视频 | 久久91精品 | 电影91久久久 | 久久精品一区二区视频 | 国产在线视频一区 | 日韩视频在线免费观看 | 国产成人精品免费视频大全最热 | 日韩一级一区 | 中文字幕在线视频免费视频 | 日韩成人在线免费观看 | 一级片av | 成人午夜电影在线观看 | 国产成人精品网站 | 国产精品久久久久av | 亚洲成人一级 | 3p视频在线观看 | 国产精品久久久久久久久免费高清 | 国产成人精品午夜 | 精品国产一区二区三区性色 | 99视频在线播放 | 国产在线a | 精品日本中文字幕 | 一级电影免费看 | 天天爽天天操 | 一本一道久久a久久精品蜜桃 | 成人福利网 | 国产一区二区三区四区 | 一区二区三区在线看 | 午夜小电影 | 久久国产一区二区 | 国产成人福利在线 | 婷婷色国产偷v国产偷v小说 | 亚洲一区中文 |