博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
K210单色块识别并框选
阅读量:3957 次
发布时间:2019-05-24

本文共 1068 字,大约阅读时间需要 3 分钟。

单色块识别并框选

在这里插入图片描述

import sensor, image,time,lcd#摄像头初始化sensor.reset()sensor.set_pixformat(sensor.RGB565)sensor.set_framesize(sensor.QVGA)sensor.set_vflip(1)   #后置拍摄模式sensor.skip_frames(10) # Let new settings take affect.sensor.set_auto_whitebal(False) # 白平衡关闭#LCD初始化lcd.init()clock = time.clock() # Tracks FPS.K=5000#the value should be measured K=length*Lm# 实际的大小=K2*直径的像素K2=10.5/101#QQVGA模式下K2=10.5/139#QVGA模式下K2=10.5/279while(True):    clock.tick() # Track elapsed milliseconds between snapshots().    img = sensor.snapshot() # Take a picture and return the image.    lcd.display(img)#lcd屏幕显示    blobs = img.find_blobs([yellow_threshold])#调用颜色阈值    if len(blobs) == 1:#如果视野中只识别到一个目标色块        # Draw a rect around the blob.        b = blobs[0]#blose[0]就是识别到的色块        img.draw_rectangle((300, 0, 50,20), color=(255,0,0))#画框(x:0-320,:0-240,横着的,竖着的)        img.draw_rectangle(b[0:4]) # rect        img.draw_cross(b[5], b[6]) # cx, cy        Lm = (b[2]+b[3])/2 #b[2]长 ,b[3]宽        length = K/Lm        print(length)#长度27        print(Lm)#像素点        size=K2*Lm        print(size)

转载地址:http://wxtzi.baihongyu.com/

你可能感兴趣的文章
野指针与空指针
查看>>
图文混排效果
查看>>
urllib2.urlopen超时问题
查看>>
Choosing a Machine Learning Classifier
查看>>
魏兴国:深入浅出DDoS攻击防御
查看>>
使连续的参考文献能够中间用破折号连起来
查看>>
Discover Feature Engineering, How to Engineer Features and How to Get Good at It
查看>>
36辆车,6条跑道,无计时器,最少几次比赛可以选出前三
查看>>
matlab2012b与matlab7.1执行set(gca,'Yscale','log')之后画到的直方图结果居然不同
查看>>
python读大文件
查看>>
python 3里没有cmp这个函数了
查看>>
回文题
查看>>
二叉树的最短根到叶路径中点的个数
查看>>
给定二叉树求最小深度
查看>>
平衡树
查看>>
栈的应用题(1)
查看>>
判断链表是否有环
查看>>
从有序链表中去掉重复的
查看>>
后台程序结果重定向到文件,结果看不到文件?缓冲区的问题
查看>>
[LeetCode]Reverse Integer
查看>>