导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. 1iht
    1
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    1iht

    @1iht

    0
    声望
    7
    楼层
    564
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    1iht 关注

    1iht 发布的帖子

    • RE: openmv颜色,形状识别出问题。

      如果面积判断设置太小的话,调试的时候会有各种颜色的物体被识别出来,包括不是红色的物体,请问是不是距离太远,亮度变了,导致摄像头识别不出来呢,如果是,如何进行改动呢?

      发布在 OpenMV Cam
      1
      1iht
    • openmv颜色,形状识别出问题。

      openmv通过图片进行颜色阈值设置后, 加上舵机,只能识别近距离的物体,远距离的物体识别不到,是什么问题呢?
      如果是光度的影响,该如何调整代码呢?

      import sensor, image, time, math
      from pyb import UART
      import json
      import ustruct
      
      sensor.reset()
      sensor.set_framesize(sensor.QQVGA)
      sensor.set_pixformat(sensor.RGB565)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      #sensor.set_auto_exposure(False,2000);  #控制曝光时间,单位为us
      #sensor.set_windowing((22,7,110,105));
      
      clock = time.clock()
      uart = UART(3,115200)   #定义串口3变量    P4 TX<-->PA10  P5 RX<-->PA9
      uart.init(115200, bits=8, parity=None, stop=1) # init with given parameters
      
      #binary_threshold = (0, 156)
      find_threshold = (20, 48, 28, 60, -5, 44)
      K = 12800;  #自己选取一个合适的校准值
      def find_max(blobs):    #定义寻找色块面积最大的函数
          blobs.sort(key=lambda x:x.pixels(),reverse=True);
          max_blob={}             #默认为空字典
          length=len(blobs);
          if length>0:
              max_blob=blobs[0];
          return max_blob;
      
      def sending_data(cx_max,cy_max):
          global uart;
          #frame=[0x2C,18,cx%0xff,int(cx/0xff),cy%0xff,int(cy/0xff),0x5B];
          #data = bytearray(frame)
          data = ustruct.pack("<bbhhb",              #格式为俩个字符俩个短整型(2字节)
                         0x2C,                       #帧头1
                         0x12,                       #帧头2
                         int(cx_max), # up sample by 4    #数据1
                         int(cy_max), # up sample by 4    #数据2LCD_ShowStringLCD_ShowString
                         0x5B);
          uart.write(data);   #必须要传入一个字节数组
      
      while(True):
          clock.tick()
          img = sensor.snapshot()#.lens_corr(1.45);
          #img.binary([binary_threshold], invert = 1)
          blobs = img.find_blobs([find_threshold],area_threshold=100)
      
      
          if blobs:
              max_blob=find_max(blobs)
              img.draw_rectangle(max_blob.rect(),color=(0,0,255))
              img.draw_cross(max_blob.cx(), max_blob.cy(),color=(0,0,255))
              img.draw_cross(160, 120,color=(0,0,255)) # 在中心点画标记
              img.draw_line((160,120,max_blob.cx(),max_blob.cy()), color=(0,0,255));
      
              phi = (max_blob.w() + max_blob.h())/2;
              length = K/phi; #获得距标靶距离
      
              #print('position:',max_blob.cx(),max_blob.cy())
              if(max_blob.pixels()>100):
                  sending_data(max_blob.cx(), max_blob.cy()); #发送点位坐标
                  #print(max_blob.pixels())
              print("Length=",length);
          else:
              sending_data(10000,10000);
          #print(clock.fps())
      
      
      
      
      发布在 OpenMV Cam
      1
      1iht
    • RE: 串口通信输出乱码,波特率,串口都没错,请问是哪里出错了呢?

      那请问怎么才能使串口助手输出数字坐标呢?代码该如何修改?
      谢谢!

      发布在 OpenMV Cam
      1
      1iht
    • RE: 串口通信输出乱码,波特率,串口都没错,请问是哪里出错了呢?

      0_1619357381528_7a3df1bf-ec2c-4169-8745-38d5bce1d1c0-image.png
      用XCOM V2.0
      串口助手收到数据是乱码

      发布在 OpenMV Cam
      1
      1iht
    • 串口通信输出乱码,波特率,串口都没错,请问是哪里出错了呢?
      import sensor, image, time,math
      import json
      import ustruct
      
      from pid import PID
      from pyb import Servo
      from pyb import UART
      
      
      pan_servo=Servo(1)
      tilt_servo=Servo(2)
      
      pan_servo.calibration(500,2500,500)
      tilt_servo.calibration(500,2500,500)
      
      green_threshold  = (52, 98, -13, -25, -26, 5)
      
      pan_pid = PID(p=0.07, i=0, imax=90) #脱机运行或者禁用图像传输,使用这个PID
      tilt_pid = PID(p=0.05, i=0, imax=90) #脱机运行或者禁用图像传输,使用这个PID
      #pan_pid = PID(p=0.1, i=0, imax=90)#在线调试使用这个PID
      #tilt_pid = PID(p=0.1, i=0, imax=90)#在线调试使用这个PID
      
      sensor.reset() # Initialize the camera sensor.
      sensor.set_pixformat(sensor.RGB565) # use RGB565.
      sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
      sensor.skip_frames(10) # Let new settings take affect.
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # turn this off.
      clock = time.clock() # Tracks FPS.
      
      def find_max(blobs):
          max_size=0
          for blob in blobs:
              if blob[2]*blob[3] > max_size:
                  max_blob=blob
                  max_size = blob[2]*blob[3]
          return max_blob
      def sending_data(cx,cy):
              global uart;
              #frame=[0x2C,18,cx%0xff,int(cx/0xff),cy%0xff,int(cy/0xff),0x5B];
              #data = bytearray(frame)
              data = ustruct.pack("<bbhhb",              #格式为俩个字符俩个短整型(2字节)
                             0x2C,                       #帧头1
                             0x12,                       #帧头2
                             int(cx), # up sample by 4    #数据1
                             int(cy), # up sample by 4    #数据2
                             0x5B)
              uart.write(data);   #必须要传入一个字节数组
      
      def recive_data():
              global uart
              if uart.any():
                  tmp_data = uart.readline();
                  print(tmp_data)
      uart = UART(3, 115200)
      uart.init(115200, bits=8, parity=None, stop=1)  #8位数据位,无校验位,1位停止位
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # Take a picture and return the image.
      
          blobs = img.find_blobs([green_threshold], area_threshold=150);
          if blobs:
                #如果找到了目标颜色
                max_b = find_max(blobs);
                # Draw a rect around the blob.
                img.draw_rectangle(max_b[0:4]) # rect
                #用矩形标记出目标颜色区域
                img.draw_cross(max_b[5], max_b[6]) # cx, cy
                img.draw_cross(160, 120) # 在中心点画标记
                #在目标颜色区域的中心画十字形标记
                cx=max_b[5];
                cy=max_b[6];
                img.draw_line((160,120,cx,cy), color=(127));
                #img.draw_string(160,120, "(%d, %d)"%(160,120), color=(127));
                img.draw_string(cx, cy, "(%d, %d)"%(cx,cy), color=(127));
                sending_data(cx,cy); #发送点位坐标
                recive_data();
      pan_output=pan_pid.get_pid(pan_error,1)/2
      tilt_output=tilt_pid.get_pid(tilt_error,1)
      pan_servo.angle(pan_servo.angle()+pan_output)
      tilt_servo.angle(tilt_servo.angle()-tilt_output)
      
      发布在 OpenMV Cam
      1
      1iht
    • openmv连舵机时动不了

      舵机需要5v-8.4v,我给舵机和openmv接5v电压,连接后舵机里面一直抖动,不进行颜色识别,有时一直按一个方向一直动,openmv 有时闪白灯,请问这是怎么回事?

      发布在 OpenMV Cam
      1
      1iht
    • 摄像头使用配来的绿色扩展板,自己另外买了(4.8-8.4V)的舵机,请问应该如何给摄像头和舵机接线呢?

      摄像头使用配来的绿色扩展板,自己另外买了(4.8-8.4V)的舵机,请问应该如何给摄像头和舵机接线呢?

      发布在 OpenMV Cam
      1
      1iht