导航

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

    dn42 发布的帖子

    • 学习slam可以用opemmv吗?

      学习slam可以用openmv吗?

      发布在 OpenMV Cam
      D
      dn42
    • openmv发送数据给arduino之后,怎么给收到的数据命名,我试了好多次,都改不了?

      这是arduino的代码

      #include <SoftwareSerial.h>
      
      SoftwareSerial softSerial(10, 11); // RX, TX
      
      typedef struct
      {
        int data[50][2] = {{0,0}};
        int len = 0;
      }List;
      List list;
      
      void setup() {
        // put your setup code here, to run once:
        softSerial.begin(9600);
        Serial.begin(9600);
      }
      
      void loop() {
        if(softSerial.available())
        {
          getList();
          for (int i=0; i<list.len; i++)
          {
            Serial.print(list.data[i][0]);
            Serial.print('\t');
            Serial.println(list.data[i][1]);
          }
          Serial.println("============");
          clearList();
        }
      }
      
      String detectString()
      {
        while(softSerial.read() != '{');
        return(softSerial.readStringUntil('}'));
      }
      void clearList()
      {
        memset(list.data, sizeof(list.data),0);
        list.len = 0;
      }
      
      void getList()
      {
        String s = detectString();
        String numStr = "";
        for(int i = 0; i<s.length(); i++)
        {
          if(s[i]=='('){
            numStr = "";
          }
          else if(s[i] == ','){
            list.data[list.len][0] = numStr.toInt();
            numStr = "";
          }
          else if(s[i]==')'){
            list.data[list.len][1] = numStr.toInt();
            numStr = "";
            list.len++;
          }
          else{
            numStr += s[i];
          }
        }
      }
      
      发布在 OpenMV Cam
      D
      dn42
    • 我想发送四个数据,但是只能接收两个,如何增加arduino接受openmv发送的数据

      OPENMV代码:

      import sensor, image, time
      import json
      from pyb import UART
      # For color tracking to work really well you should ideally be in a very, very,
      # very, controlled enviroment where the lighting is constant...
      yellow_threshold   = ( 46,  100,  -68,   72,   58,   92)
      # You may need to tweak the above settings for tracking green things...
      # Select an area in the Framebuffer to copy the color settings.
      
      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.
      
      uart = UART(3, 115200)
      
      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([yellow_threshold],area_threshold=3000)
          if blobs:
              data=[]
              max_blob = find_max(blobs)
      
      
              img.draw_rectangle(max_blob[0:4])
              img.draw_cross(max_blob[5], max_blob[6]) # cx, cy
              data.append((max_blob[5], max_blob[6],max_blob[2],max_blob[3]))
      
              #{(1,22),(-3,33),(22222,0),(9999,12),(0,0)}
              data_out = json.dumps(set(data))
              uart.write(data_out +'\n')
              print('you send:',data_out)
          else:
              print("not found!")
      

      ARDUINNO代码

      #include <SoftwareSerial.h>
      
      SoftwareSerial softSerial(10, 11); // RX, TX
      
      typedef struct
      {
        int data[50][3] = {{0,0,0}};
        int len = 0;
      }List;
      List list;
      
      void setup() {
        // put your setup code here, to run once:
        softSerial.begin(115200);
        Serial.begin(115200);
      }
      
      void loop() {
        if(softSerial.available())
        {
          getList();
          for (int i=0; i<list.len; i++)
          {
            Serial.print(list.data[i][0]);
            Serial.print('\t');
            Serial.println(list.data[i][1]);
            Serial.print('\n');
            Serial.println(list.data[i][2]);
            Serial.print('\t');
            Serial.println(list.data[i][3]);
          }
          Serial.println("============");
          clearList();
        }
      }
      
      String detectString()
      {
        while(softSerial.read() != '{');
        return(softSerial.readStringUntil('}'));
      }
      void clearList()
      {
        memset(list.data, sizeof(list.data),0);
        list.len = 0;
      }
      
      void getList()
      {
        String s = detectString();
        String numStr = "";
        for(int i = 0; i<s.length(); i++)
        {
          if(s[i]=='('){
            numStr = "";
          }
          else if(s[i] == ','){
            list.data[list.len][0] = numStr.toInt();
            list.data[list.len][1] = numStr.toInt();
            list.data[list.len][2] = numStr.toInt();
            numStr = "";
          }
          else if(s[i]==')'){
            list.data[list.len][3] = numStr.toInt();
            numStr = "";
            list.len++;
          }
          else{
            numStr += s[i];
          }
        }
      }
      
      发布在 OpenMV Cam
      D
      dn42
    • RE: openmv能控制无人机去识别字母吗,如何实现?

      特征识别,这个比匹配要好

      发布在 OpenMV Cam
      D
      dn42
    • I2C协议中,发送物体的位置,发送不了,如何解决?

      import sensor, image, time

      import pyb , ustruct

      yellow_threshold = ( 46, 100, -68, 72, 58, 92)

      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.

      while(True):
      clock.tick() # Track elapsed milliseconds between snapshots().
      img = sensor.snapshot() # Take a picture and return the image.
      blobs = img.find_blobs([yellow_threshold], area_threshold = 2000)
      if blobs:
      #print('sum : %d'% len(blobs))

          text=[]
      
          for b in blobs:
      
              # Draw a rect around the blob.
      
              img.draw_rectangle(b.rect()) # rect
      
              img.draw_cross(b.cx(), b.cy()) # cx, cy
      
              text = "int(b.cx()), int(b.cy())"
      
          data = ustruct.pack("<%ds" % len(text), text)
      

      bus = pyb.I2C(2, pyb.I2C.SLAVE, addr=0x12)
      bus.deinit() # 完全关闭设备
      bus = pyb.I2C(2, pyb.I2C.SLAVE, addr=0x12)
      print("Waiting for Arduino...")

      请注意,为了正常同步工作,OpenMV Cam必须 在Arduino轮询数据之前运行此脚本。

      否则,I2C字节帧会变得乱七八糟。所以,保持Arduino在reset状态,

      直到OpenMV显示“Waiting for Arduino...”。

      while(True):
      try:
      bus.send(ustruct.pack("<h", len(data)), timeout=10000) # 首先发送长度 (16-bits).
      try:
      bus.send(data, timeout=10000) # 然后发送数据
      print("Sent Data!") # 没有遇到错误时,会显示
      except OSError as err:
      pass

      except OSError as err:
          pass
      发布在 OpenMV Cam
      D
      dn42
    • 在小球测距的时候,视野多出一个小球,如何保持测的是第一个小球

      import sensor, image, time

      For color tracking to work really well you should ideally be in a very, very,

      very, controlled enviroment where the lighting is constant...

      yellow_threshold = ( 56, 83, 5, 57, 63, 80)

      You may need to tweak the above settings for tracking green things...

      Select an area in the Framebuffer to copy the color settings.

      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.

      K=5000#the value should be measured

      while(True):
      clock.tick() # Track elapsed milliseconds between snapshots().
      img = sensor.snapshot() # Take a picture and return the image.

      blobs = img.find_blobs([yellow_threshold])
      if len(blobs) == 1:
          # Draw a rect around the blob.
          b = blobs[0]
          img.draw_rectangle(b[0:4]) # rect
          img.draw_cross(b[5], b[6]) # cx, cy
          Lm = (b[2]+b[3])/2
          length = K/Lm
          print(length)
      发布在 OpenMV Cam
      D
      dn42
    • openmv连着openmv IDE的时候,连不上串口助手。用的是USB-TTL,这是为什么?

      openmv连不上串口助手

      发布在 OpenMV Cam
      D
      dn42
    • 我想识别一种不同位置的相同颜色块,并且把把颜色块的坐标输出来传给arduino,需要怎么搞?

      我想识别一种不同位置的相同颜色块,并且把把颜色块的坐标输出来传给arduino,需要怎么搞?

      发布在 OpenMV Cam
      D
      dn42