导航

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

    oswy 发布的帖子

    • arduinoJson版本问题,出错哪里应该怎么改?
      #include <ArduinoJson.h>
      
      volatile int cx;
      volatile int cy;
      volatile char c;
      String json;
      
      void setup(){
        cx = 0;
        cy = 0;
        c = 0;
        json = "";
        Serial.begin(9600);
      }
      
      void loop(){
        if (Serial.available() > 0) {
          c = char(Serial.read());
          json = String(json) + String(c);
          if (c == '}') {
            StaticJsonBuffer<200> jsonBuffer;//出错
            JsonObject& root = jsonBuffer.parseObject(json);//出错
            
            int cx = root["cx"];
            int cy = root["cy"];
            Serial.print("cx = ");
            Serial.print(cx);
            Serial.print('\t');
            Serial.print("cy = ");
            Serial.println(cy);
            json = "";
          }
        }
      }
      

      exit status 1
      StaticJsonBuffer is a class from ArduinoJson 5. Please see arduinojson.org/upgrade to learn how to upgrade your program to ArduinoJson version 6

      发布在 OpenMV Cam
      O
      oswy
    • 有ArduinoJson.h的库文件吗?
      #include <ArduinoJson.h>
      
      exit status 1
      ArduinoJson.h: No such file or directory
      
      发布在 OpenMV Cam
      O
      oswy
    • RE: pca9685控制舵机,接线没问题,报错,程序停在这一步是为什么?

      还会停在这一步
      self.i2c.writeto_mem(self.address, 0x06 + 4 * index, data)
      main.py和servo.py都是只改动了舵机相关的参数。

      发布在 OpenMV Cam
      O
      oswy
    • pca9685控制舵机,接线没问题,报错,程序停在这一步是为什么?

      0_1564456069573_0c49adaa-3d56-4d44-b87b-9faa07223a27-image.png

      import utime
      import ustruct
      
      class PCA9685:
          def __init__(self, i2c, address=0x40):
              self.i2c = i2c
              self.address = address
              self.reset()
      
          def _write(self, address, value):
              self.i2c.writeto_mem(self.address, address, bytearray([value]))//程序停在这一步报错?
      
          def _read(self, address):
              return self.i2c.readfrom_mem(self.address, address, 1)[0]
      
          def reset(self):
              self._write(0x00, 0x00) # Mode1
      
          def freq(self, freq=None):
              if freq is None:
                  return int(25000000.0 / 4096 / (self._read(0xfe) - 0.5))
              prescale = int(25000000.0 / 4096.0 / freq + 0.5)
              old_mode = self._read(0x00) # Mode 1
              self._write(0x00, (old_mode & 0x7F) | 0x10) # Mode 1, sleep
              self._write(0xfe, prescale) # Prescale
              self._write(0x00, old_mode) # Mode 1
              utime.sleep_us(5)
              self._write(0x00, old_mode | 0xa1) # Mode 1, autoincrement on
      
          def pwm(self, index, on=None, off=None):
              if on is None or off is None:
                  data = self.i2c.readfrom_mem(self.address, 0x06 + 4 * index, 4)
                  return ustruct.unpack('<HH', data)
              data = ustruct.pack('<HH', on, off)
              self.i2c.writeto_mem(self.address, 0x06 + 4 * index,  data)
      
          def duty(self, index, value=None, invert=False):
              if value is None:
                  pwm = self.pwm(index)
                  if pwm == (0, 4096):
                      value = 0
                  elif pwm == (4096, 0):
                      value = 4095
                  value = pwm[1]
                  if invert:
                      value = 4095 - value
                  return value
              if not 0 <= value <= 4095:
                  raise ValueError("Out of range")
              if invert:
                  value = 4095 - value
              if value == 0:
                  self.pwm(index, 0, 4096)
              elif value == 4095:
                  self.pwm(index, 4096, 0)
              else:
                  self.pwm(index, 0, value)
      
      
      
      发布在 OpenMV Cam
      O
      oswy
    • RE: openmv自带的函数库中有张正友标定法的吗?

      相机和标定板,计算相机的外参

      发布在 OpenMV Cam
      O
      oswy
    • openmv自带的函数库中有张正友标定法的吗?

      findChessboardCorners
      检测标定板内角点或亚像素点

      发布在 OpenMV Cam
      O
      oswy
    • RE: 识别出图片中两个一样的,区别于左下,特征点检测特征点太少,有什么好的办法区分吗

      识别出中间是黄色圆的图案,不识别左下的那个

      发布在 OpenMV Cam
      O
      oswy
    • 识别出图片中两个一样的,区别于左下,特征点检测特征点太少,有什么好的办法区分吗

      ![0_1564038826855_QQ图片20190719141214.jpg](正在上传0_1564038851100_QQ图片20190719141214.jpg 0

      发布在 OpenMV Cam
      O
      oswy
    • blobs.x()和blobs.y()返回色块在图像中的x,y坐标能否转化为空间的三位坐标?

      blob.x()
      返回色块的边界框的x坐标(int)。

      您也可以通过索引 [0] 取得这个值。

      blob.y()
      返回色块的边界框的y坐标(int)。

      您也可以通过索引 [1] 取得这个值。

      发布在 OpenMV Cam
      O
      oswy
    • 能不能详细解释下这段代码里的舵机控制部分(最后五行)?
      import sensor, image, time
      
      from pid import PID
      from pyb import Servo
      
      pan_servo=Servo(1)
      tilt_servo=Servo(2)
      
      red_threshold  = (13, 49, 18, 61, 6, 47)
      
      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_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
      
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # Take a picture and return the image.
      
          blobs = img.find_blobs([red_threshold])
          if blobs:
              max_blob = find_max(blobs)
              pan_error = max_blob.cx()-img.width()/2
              tilt_error = max_blob.cy()-img.height()/2
      
              print("pan_error: ", pan_error)
      
              img.draw_rectangle(max_blob.rect()) # rect
              img.draw_cross(max_blob.cx(), max_blob.cy()) # cx, cy
      
              pan_output=pan_pid.get_pid(pan_error,1)/2
              tilt_output=tilt_pid.get_pid(tilt_error,1)
              print("pan_output",pan_output)
              pan_servo.angle(pan_servo.angle()+pan_output)
              tilt_servo.angle(tilt_servo.angle()-tilt_output)
      
      发布在 OpenMV Cam
      O
      oswy
    • 颜色和形状同时识别,怎么设置面积小于1的圆不识别?
      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      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
      clock = time.clock()
      
      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(1.8)
          for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,
                  r_min = 2, r_max = 100, r_step = 2):
              area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())
              #area为识别到的圆的区域,即圆的外接矩形框
              statistics = img.get_statistics(roi=area)#像素颜色统计
              print(statistics)
              #(0,100,0,120,0,120)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是黄色的圆。
              #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
              
              if (r*r)>1
                  if 0<statistics.l_mode()<88 and 0<statistics.a_mode()<127 and 0<statistics.b_mode()<127:#if the circle is red
                      img.draw_circle(c.x(), c.y(), c.r(), color = (255, 255, 0))#识别到的黄色圆形用黄色的圆框出来
                      img.draw_cross(c.x(), c.y())
              else:
                  img.draw_rectangle(area, color = (255, 255, 255))
                  #将非红色的圆用白色的矩形框出来
          print("FPS %f" % clock.fps())
      
      
      发布在 OpenMV Cam
      O
      oswy
    • RE: 颜色和形状同时识别,怎么调高图像分辨率?

      QQVGA已经是允许的最大分辨率吗?如果不是,最大是多少呢

      发布在 OpenMV Cam
      O
      oswy
    • 颜色和形状同时识别,怎么调高图像分辨率?
      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      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
      clock = time.clock()
      
      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(1.8)
          for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,
                  r_min = 2, r_max = 100, r_step = 2):
              area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())
              #area为识别到的圆的区域,即圆的外接矩形框
              statistics = img.get_statistics(roi=area)#像素颜色统计
              print(statistics)
              #(0,100,0,120,0,120)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是红色的圆。
              #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
              if 0<statistics.l_mode()<100 and 0<statistics.a_mode()<127 and 0<statistics.b_mode()<127:#if the circle is red
                  img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))#识别到的红色圆形用红色的圆框出来
              else:
                  img.draw_rectangle(area, color = (255, 255, 255))
                  #将非红色的圆用白色的矩形框出来
          print("FPS %f" % clock.fps())
      
      
      发布在 OpenMV Cam
      O
      oswy