导航

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

    chep 发布的帖子

    • openmv如果要做激光扫描三维重建测量物体尺寸要怎么实现

      openmv如果要做激光扫描三维重建测量物体尺寸要怎么实现

      发布在 OpenMV Cam
      C
      chep
    • RE: 为什么这段代码里面 颜色分割部分会报错

      能帮修复整一个完整代码吗

      发布在 OpenMV Cam
      C
      chep
    • 为什么这段代码里面 颜色分割部分会报错
      import sensor, image, time
      from pyb import Pin, LED
      
      # 初始化相机、LED灯和引脚
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      led = LED(3)
      pin1 = Pin('P1', Pin.OUT_PP)
      
      # 预设颜色阈值
      green_threshold = (72, 100, -1, 82, -11, 101)
      red_threshold = (0, 50, 20, 80, -10, 40)
      
      while True:
          
          # 获取图像并处理
          img = sensor.snapshot()
          
          # 进行颜色分割
          green_mask = img.color_threshold(green_threshold)
          red_mask = img.color_threshold(red_threshold)
          
          # 对颜色分割进行形态学操作
          green_mask.erode(1)
          green_mask.dilate(2)
          red_mask.erode(1)
          red_mask.dilate(2)
          
          # 对颜色分割进行轮廓检测
          green_blobs = green_mask.find_blobs(min_area=500)
          red_blobs = red_mask.find_blobs(min_area=500)
          
          # 数量统计到count变量中
          count = len(green_blobs) + len(red_blobs)
          
          # 判断数量是否大于等于2,输出电平和点亮LED蓝灯
          if count >= 2:
              pin1.low()
              led.on()
          else:
              pin1.high()
              led.off()
      

      为什么这段代码里面green_mask = img.color_threshold(green_threshold)段会报错找不到原因

      发布在 OpenMV Cam
      C
      chep
    • 在这个代码里面怎么插入一个颜色识别,然后识别到颜色P0输出一个低电平信号,识别到神经网络模型,P1输出一个低电平信号。
      # Edge Impulse - OpenMV Image Classification Example
      
      import sensor, image, time, os, tf, uos, gc
      
      sensor.reset()                         # Reset and initialize the sensor.
      sensor.set_pixformat(sensor.RGB565)    # Set pixel format to RGB565 (or GRAYSCALE)
      sensor.set_framesize(sensor.QVGA)      # Set frame size to QVGA (320x240)
      sensor.set_windowing((240, 240))       # Set 240x240 window.
      sensor.skip_frames(time=2000)          # Let the camera adjust.
      
      net = None
      labels = None
      
      try:
          # load the model, alloc the model file on the heap if we have at least 64K free after loading
          net = tf.load("trained.tflite", load_to_fb=uos.stat('trained.tflite')[6] > (gc.mem_free() - (64*1024)))
      except Exception as e:
          print(e)
          raise Exception('Failed to load "trained.tflite", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      
      try:
          labels = [line.rstrip('\n') for line in open("labels.txt")]
      except Exception as e:
          raise Exception('Failed to load "labels.txt", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      
      clock = time.clock()
      while(True):
          clock.tick()
      
          img = sensor.snapshot()
      
          # default settings just do one detection... change them to search the image...
          for obj in net.classify(img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5):
              print("**********\nPredictions at [x=%d,y=%d,w=%d,h=%d]" % obj.rect())
              img.draw_rectangle(obj.rect())
              # This combines the labels and confidence values into a list of tuples
              predictions_list = list(zip(labels, obj.output()))
      
              for i in range(len(predictions_list)):
                  print("%s = %f" % (predictions_list[i][0], predictions_list[i][1]))
      
          print(clock.fps(), "fps")
      
      
      发布在 OpenMV Cam
      C
      chep
    • RE: 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出

      @kidswong999 在 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出 中说:

      enable_lens_corr = False

      import sensor, image, time

      sensor.reset()
      sensor.set_pixformat(sensor.RGB565) # 灰度更快
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      clock = time.clock()

      pin1 = Pin('P1', Pin.OUT_PP, Pin.PULL_NONE)
      pin1.value(0)

      while(True):
      clock.tick()
      img = sensor.snapshot()
      if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...
      segments = img.find_line_segments(merge_distance = 0, max_theta_diff = 5)
      result_segments = []

      for l in segments:
          if l.length() > 50:
              result_segments.append(l)
      
      if len(result_segments) > 5:
          pin1.value(1)
      else:
          pin1.value(0)
      for l in result_segments:
          img.draw_line(l.line(), color = (255, 0, 0))
          # print(l)
      
      print("FPS %f" % clock.fps())
      

      现在是可以过滤掉短的了 ,然后有一个就是 这个有办法过滤掉,好的线段的跳动吗?跳动变动,输出信号不稳定,

      发布在 OpenMV Cam
      C
      chep
    • RE: 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出

      @kidswong999 在 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出 中说:

      result_segments = []

      for l in segments:
      if l.length() > 50:
      result_segments.append(l)

      这段代码放上去过滤不了 短的线 没效果

      发布在 OpenMV Cam
      C
      chep
    • RE: 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出

      @kidswong999 在吗 在吗过滤短的线条

      发布在 OpenMV Cam
      C
      chep
    • RE: 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出

      @kidswong999 你好!在吗?怎么过滤掉那个比较短的线。或者说只识别边缘的线段就可以。可以这样设置吗

      发布在 OpenMV Cam
      C
      chep
    • RE: 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出

      @kidswong999 哦 放进去了 就是还有很多出现很短的线 要怎么屏蔽过滤

      发布在 OpenMV Cam
      C
      chep
    • RE: 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出

      @kidswong999 非常感谢!要怎么插入到那段代码上呢,刚贴进去,报错

      发布在 OpenMV Cam
      C
      chep
    • RE: 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出

      @kidswong999 这段代码要怎么加一段 能过滤掉一些短的线 或不直的线段 要怎么过滤?

      发布在 OpenMV Cam
      C
      chep
    • RE: 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出

      @kidswong999 谢谢了!非常感谢!

      发布在 OpenMV Cam
      C
      chep
    • 怎么在这个代码里添加一个线段数量值然后达到线段数量比如识别5条线段后输出到一个引脚作低电平信号输出
      # 线段检测例程
      #
      # 这个例子展示了如何在图像中查找线段。对于在图像中找到的每个线对象,
      # 都会返回一个包含线条旋转的线对象。
      
      # find_line_segments()找到有限长度的线(但是很慢)。
      # Use find_line_segments()找到非无限的线(而且速度很快)。
      
      enable_lens_corr = False # turn on for straighter lines...打开以获得更直的线条…
      
      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565) # 灰度更快
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      
      # 所有线段都有 `x1()`, `y1()`, `x2()`, and `y2()` 方法来获得他们的终点
      # 一个 `line()` 方法来获得所有上述的四个元组值,可用于 `draw_line()`.
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...
      
          # `merge_distance`控制附近行的合并。 在0(默认),没有合并。 
          # 在1处,任何距离另一条线一个像素点的线都被合并...等等,
          # 因为你增加了这个值。 您可能希望合并线段,因为线段检测会产生大量
          # 的线段结果。
      
          # `max_theta_diff` 控制要合并的任何两线段之间的最大旋转差异量。
          # 默认设置允许15度。
      
          for l in img.find_line_segments(merge_distance = 0, max_theta_diff = 5):
              img.draw_line(l.line(), color = (255, 0, 0))
              # print(l)
      
          print("FPS %f" % clock.fps())
      
      发布在 OpenMV Cam
      C
      chep