logo

为什么更新IDE后采集速度没有变化?

2020-06-21 09:22
5
yzrl

之前说过更新后采集速度会变快很多,但为什么我的帧率还是一样的数值(75)?速度也没有提升?之前的提问:https://forum.singtown.com/topic/5009/这个代码需要如何优化才能提速

2020-06-22 16:01
I
网红小智智 星瞳科技

禁用帧缓冲区。硬件:OpenMV4,7725,固件2.6.4。

ea11116e-6b13-4972-a3b5-92c5697f9e4b.png
2020-06-24 09:30
5
yzrl
579ed990-d1c4-4f90-a9d4-0c7e46cc8e76.jpg
# 红外RGB565跟踪示例

#

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


import sensor, image
import time
#from numba import jit
from pyb import UART

import json
import utime

import pyb

#EXPOSURE_TIME_SCALE = 0.1
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=100)#设置曝光


#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):
    #utime.sleep_ms(50)

    #for i in range(0,6000):
    clock.tick()# Track elapsed milliseconds between snapshots().

    img = sensor.snapshot()#binary([thresholds], invert=True, zero=True)
   # TimeBox[1]= TimeBox[0]
   # TimeBox[0] = utime.ticks_ms()
    #deal = utime.ticks_diff(TimeBox[0],TimeBox[1])
    #print("deal :",deal)
   # start = utime.ticks_ms()
    blobs=img.find_blobs([thresholds],pixels_threshold=200,area_threshold=250)


    if blobs:

      output_str = json.dumps(blobs)

      max_blob=find_max(blobs)

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

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

      print('you send:',output_str)
      uart.write(output_str+'\n')

     # print("Initial exposure == %d" % sensor.set_auto_exposure())

      #current_exposure_time_in_microseconds=sensor.get_exposure_us()

      #sensor.set_auto_exposure(False, \'
         # exposure_us = int(sensor.get_exposure_us() * EXPOSURE_TIME_SCALE))
      print("New exposure == %d" % sensor.get_exposure_us())

      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-26 14:46
I
网红小智智 星瞳科技

运行hello world。

2020-06-26 17:09
5
yzrl

运行这个代码速度不能达到吗?

2020-06-26 23:13
I
网红小智智 星瞳科技

不同的代码不一样。

你的代码里,sensor.get_exposure_us()耗时,删掉。

曝光时间和帧率也有关系。sensor.set_auto_exposure(False,exposure_us=100)改一下。

具体怎么改看你的需求。

2020-06-29 00:21
5
yzrl

串口发送“uart = UART(3,115200)”,这一行就导致速度提不上去,但这行又不能缺少,有办法解决吗?

2020-06-29 02:28
I
网红小智智 星瞳科技

uart.write(output_str+'\n')发送数据会变慢。你可以换一下协议,发送二进制。

这个代码是可以的。

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:
        max_blob=find_max(blobs)
        output = bytes([0xFF,max_blob.cx(),max_blob.cy()])
        print('you send:',output)
        uart.write(output)
        print("FPS:", clock.fps())
2020-06-29 22:11
5
yzrl

好像还是不行,有了uart = UART(3,115200)就会变慢

# 红外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:17
I
网红小智智 星瞳科技

测试代码:

# 红外RGB565跟踪示例

#

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


import sensor, image
import time
#from numba import jit
from pyb import UART

import json
import utime

import pyb

#EXPOSURE_TIME_SCALE = 0.1
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=100)#设置曝光


#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:
        max_blob=find_max(blobs)
        output = bytes([0xFF,max_blob.cx(),max_blob.cy()])
        print('you send:',output)
        uart.write(output)
        print("FPS:", clock.fps())

测试结果:FPS: 136.1621

581287df-825a-4800-9997-85ca2b8a4217.png
2020-06-30 20:39
5
yzrl
9ad81759-61fa-41d8-a6dd-61ab288ae8c9.png
2020-07-01 19:42
I
网红小智智 星瞳科技

不知道具体情况,建议联系卖家,把产品寄回去测试。

2020-07-14 13:49
I
网红小智智 星瞳科技

OpenMV4 ov7725 hello world可以到150帧,加入其他的代码不能保证是150帧。