logo

脱机运行为什么无法成功?

2020-06-29 00:16
5
yzrl
028fbe22-0aa3-445c-b652-4e4893d4c99a.png
2020-06-29 02:01
I
网红小智智 星瞳科技

https://book.openmv.cc/example/02-Board-Control/led-control.html

先脱机运行这个程序,通过LED判断是否运行程序。

2020-06-29 22:14
5
yzrl

这个可以运行,但是自己写的不行

# 红外RGB565跟踪示例

#

# 这个例子展示了使用OpenMV Cam进行红外RGB565跟踪。


import sensor, image
import time
from pyb import UART

import json
import utime

import pyb

thresholds = (100,100,0,0,0,0) # thresholds for bright white light from IR.

TimeBin = [0,0]
TimeBox = [0,0]

sensor.reset()

sensor.set_pixformat(sensor.RGB565)

sensor.set_framesize(sensor.QQQVGA)

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.skip_frames(time = 10)
#sensor.get_exposure_us()#以毫秒为单位返回曝光率

#sensor.set_auto_exposure(False,exposure_us=1)#设置曝光


#sensor.set_auto_exposure(False, \
   # exposure_us = int(current_exposure_time_in_microseconds* EXPOSURE_TIME_SCALE))


clock = time.clock() # Tracks FPS.

uart = UART(3,115200)



def find_max(blobs):
   max_size=0
   for blob in blobs:
        if blob.pixels() >max_size:
            max_blob=blob
            max_size = blob.pixels()
   return max_blob



while(True):

    clock.tick()# Track elapsed milliseconds between snapshots().

    img = sensor.snapshot()#binary([thresholds], invert=True, zero=True)

    blobs=img.find_blobs([thresholds],pixels_threshold=200,area_threshold=250)


    if blobs:

      #output_str = json.dumps(blobs)

      max_blob=find_max(blobs)
      output = bytes([0xFF,max_blob.cx(),max_blob.cy()])

      img.draw_rectangle(max_blob.rect(),color=(255,0,0))

      #output_str="[%d,%d]" % (max_blob.cx(),max_blob.cy())

      print('you send:',output)
      uart.write(output)

      TimeBin[1] = TimeBin[0]
      TimeBin[0] = utime.ticks_ms()
      delta= utime.ticks_diff(TimeBin[0], TimeBin[1])
      print('duration:',delta)

      print("FPS:", clock.fps())

            #img.draw_cross(blob.cx(), blob.cy())
    #else:

                #print('not found!')
2020-06-30 01:18
I
网红小智智 星瞳科技

你是通过什么现象判断是否脱机运行的?

I
网红小智智 星瞳科技

步骤按照视频操作,通过IDE的保存工具。

https://singtown.com/learn/49976/

2020-06-30 20:28
5
yzrl

@kidswong999 我这个是红外光识别,脱机后对准红外手电,但右上角屏幕没有任何显示

2020-07-01 19:33
I
网红小智智 星瞳科技

脱机运行与电脑完全无关,哪来的屏幕?

2020-07-01 22:35
5
yzrl

哦哦哦对,它是没有传输识别出来坐标