为什么跑mnist例程的代码,正确率这么低
请在这里粘贴代码
# This code run in OpenMV4 H7 or OpenMV4 H7 Plus
import sensor, image, time, os, tf
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # 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.
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot().binary([(0,64)])
for obj in tf.classify("trained.tflite", img, min_scale=1.0, scale_mul=0.5, x_overlap=0.0, y_overlap=0.0):
output = obj.output()
number = output.index(max(output))
print(number)
print(clock.fps(), "fps")
请问openmv的初始化可以在while(ture)里面进行变更吗
# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!
import sensor, image, time
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQVGA # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.
while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected
# to the IDE. The FPS should increase once disconnected.
我就是想在一个代码程序里面用两种VGA,代码应该怎么写
新买的openmvh7plus,运行模板的hello word代码为什么这么暗,用之前不是plus的就很亮,代码一样的
# 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
#
# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!
import sensor
import time
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.skip_frames(time=2000) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.
while True:
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected
# to the IDE. The FPS should increase once disconnected.
AttributeError: 'module' object has no attribute 'classify"
用星瞳ai训练的模型用h7plus报这个错误要怎么解决呢
This code run in OpenMV4 H7 Plus
import sensor, image, time, os, tf
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.
labels = [line.rstrip() for line in open("labels.txt")]
class_num = len(labels)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
for obj in tf.classify("trained.tflite", img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5):
img.draw_rectangle(obj.rect())
output = obj.output()
for i in range(class_num):
print("%s = %f" % (labels[i], output[i]))
print(clock.fps(), "fps")
sensor.sensor_sleep(enable)
import network, usocket
import sensor, image, pyb
import ubinascii
import json
import time
import sys
..........
运行后:
Traceback (most recent call last):
File "
File "
AttributeError: 'module' object has no attribute 'sensor_sleep'
没有这个sleep的功能么??
求教:怎么将Openmv识别的二维码显示在lcd上面
import sensor, image
import lcd
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA2) # can be QVGA on M7...
sensor.skip_frames(30)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
while(True):
img = sensor.snapshot()
img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
for code in img.find_qrcodes():
img.draw_string(10,10,code.payload())
lcd.display(img)
RuntimeError: Sensor control failed
如果涉及代码,需要报错提示与全部代码文本,请注意不要贴代码图片
sensor型号是什么?
OpenMV的硬件型号是什么?
固件版本是什么?
openmv拍摄的彩色图片的规模为什么是 w*h*2,而不是w*h,多出来的部分是什么含义?
Untitled - By: 49053 - 周二 4月 5 2022
import sensor, image, time
from pyb import UART
threshold = (0,255,0,255,0,255)
uart = UART(3,9600)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)#GRAYSCALE
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
img = sensor.snapshot()
print(img)
print(img[1])
蒙版mask使用问题
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.SXGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
x=544
y=515
radius1=286
radius2=350
mask = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.GRAYSCALE)
mask.replace(sensor.snapshot().to_grayscale().clear().invert())
mask.draw_circle((x,y,radius2),color=0,fill=True)
while(True):
clock.tick()
img = sensor.snapshot().clear(mask=mask)
print(clock.fps())
怎样得到物块位置
import sensor, image, timered_threshold_01 = (0, 35, 0, 50, -10, 40)sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(10) sensor.set_auto_whitebal(False)clock = time.clock() while(True): clock.tick() img = sensor.snapshot() blobs = img.find_blobs([red_threshold_01], area_threshold=150) if blobs: print(blobs) for b in blobs: img.draw_rectangle(b[0:4]) img.draw_cross(b[5], b[6]) print(cx,cy) print(clock.fps())