• OpenMV VSCode 扩展发布了,在插件市场直接搜索OpenMV就可以安装
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 根据寻到产生一个角度,但后面没有循线的过程,没有告诉小车怎么做,后面的这段程序在哪里,我想看一下效果,谢谢。



    • 
      # This work is licensed under the MIT license.
      # Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
      # https://github.com/openmv/openmv/blob/master/LICENSE
      #
      # Black Grayscale Line Following Example
      #
      # Making a line following robot requires a lot of effort. This example script
      # shows how to do the machine vision part of the line following robot. You
      # can use the output from this script to drive a differential drive robot to
      # follow a line. This script just generates a single turn value that tells
      # your robot to go left or right.
      #
      # For this script to work properly you should point the camera at a line at a
      # 45 or so degree angle. Please make sure that only the line is within the
      # camera's field of view.
      
      import sensor
      import time
      import math
      
      # Tracks a black line. Use [(128, 255)] for a tracking a white line.
      GRAYSCALE_THRESHOLD = [(0, 64)]
      
      # Each roi is (x, y, w, h). The line detection algorithm will try to find the
      # centroid of the largest blob in each roi. The x position of the centroids
      # will then be averaged with different weights where the most weight is assigned
      # to the roi near the bottom of the image and less to the next roi and so on.
      ROIS = [  # [ROI, weight]
          (0, 100, 160, 20, 0.7),  # You'll need to tweak the weights for your app
          (0, 50, 160, 20, 0.3),  # depending on how your robot is setup.
          (0, 0, 160, 20, 0.1),
      ]
      
      # Compute the weight divisor (we're computing this so you don't have to make weights add to 1).
      weight_sum = 0
      for r in ROIS:
          weight_sum += r[4]  # r[4] is the roi weight.
      
      # Camera setup...
      sensor.reset()  # Initialize the camera sensor.
      sensor.set_pixformat(sensor.GRAYSCALE)  # use grayscale.
      sensor.set_framesize(sensor.QQVGA)  # use QQVGA for speed.
      sensor.skip_frames(time=2000)  # Let new settings take affect.
      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()  # Tracks FPS.
      
      while True:
          cl