OpenMV H7相机模块的独特之处在于它支持多个不同的相机模块。例如,如果开发人员不想使用分辨率为640 x 480的板载相机,则可以切换到支持ON Semiconductor的MT9V034图像传感器的模块。MT9V034是一款1/3英寸宽的VGA格式CMOS有源像素数字图像传感器,包含全局快门和高动态范围 (HDR) 模式。该传感器的图像分辨率为752 x 480,设计用于-30˚C至+70˚C的宽温度范围。ON Semiconductor为此图像传感器提供了一款开发板,即MT9V034C12STCH-GEVB(图4)。
# 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.QVGA) # Set frame size to QVGA
(320×240) 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.
清单 1:OpenMV IDE hello_world.py 应用能够使 OpenMV 相机模块提供实时视频。 (代码来源:OpenMV)
为了执行第一次物体检测和分类测试,需要使用所需的物体识别类来训练ML网络。CIFAR-10数据集是一个常用图像数据集,可用于训练物体检测模型并测试模型运行状况。CIFAR-10数据集含有60,000张图片,其中包含以下10种不同图像类别的32 x 32彩色图像:
# CIFAR-10 Search Whole
Window Example # # CIFAR is a convolutional neural network designed to classify
its field of view into several # different object types and works on RGB video
data.# # In this example we slide the LeNet detector window over the image and
get a list of activations # where there might be an object.Note that use a CNN
with a sliding window is extremely compute # expensive so for an exhaustive
search do not expect the CNN to be real-time.import sensor, image, time, os, nn
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
(320×240) sensor.set_windowing((128, 128)) # Set 128×128
window.sensor.skip_frames(time=750) # Don’t let autogain run
very long.sensor.set_auto_gain(False) # Turn off
autogain.sensor.set_auto_exposure(False) # Turn off whitebalance.#
Load cifar10 network (You can get the network from OpenMV IDE).net = nn.load(‘/cifar10.network’) # Faster, smaller and
less accurate.# net = nn.load(‘/cifar10_fast.network’) labels = [‘airplane’, ‘automobile’, ‘bird’, ‘cat’, ‘deer’, ‘dog’, ‘frog’, ‘horse’, ‘ship’, ‘truck’] clock = time.clock()
while(True): clock.tick() img = sensor.snapshot() # net.search() will
search an roi in the image for the network (or the whole image if the roi is
not # specified).At each location to look in the
image if one of the classifier outputs is larger than # threshold the location
and label will be stored in an object list and returned.At each scale the # detection window is
moved around in the ROI using x_overlap (0-1) and y_overlap (0-1) as a guide.#
If you set the overlap to 0.5 then each detection window will overlap the
previous one by 50%.Note # the computational work
load goes WAY up the more overlap.Finally, for mult-scale matching after # sliding the network
around in the x/y dimensions the detection window will shrink by scale_mul
(0-1) # down to min_scale (0-1).For example, if
scale_mul is 0.5 the detection window will shrink by 50%.# Note that at a lower
scale there’s even more area to search if x_overlap and y_overlap are small…#
contrast_threshold skips running the CNN in areas that are flat.for obj in
net.search(img, threshold=0.6, min_scale=0.5, scale_mul=0.5, \ x_overlap=0.5,
y_overlap=0.5, contrast_threshold=0.5): print(“Detected%s–Confidence%f%%” % (labels[obj.index()],
obj.value()))
img.draw_rectangle(obj.rect(), color=(255, 0, 0)) print(clock.fps())
清单 2:OpenMV IDE nn_cifar10_search_whole_window.py示例应用可用于对图像进行分类, 并为分类提供置信度测量。(代码来源:OpenMV)
功率更大:USB PD 3.0提供功率高达100W (5A x 20V),可为平板电脑和便携式计算机快速充电。
USB Type-C连接器对于USB 3.2第2 x 2代规范必不可少,今后该标准的新版本将只兼容这类连接器(而不兼容Type-A和Type-B连接器)。该规范定义了24针连接器,即四个+5 V接地引脚、两对用于USB 2.0数据总线差分信号、四对用于SuperSpeed数据总线、两个“辅助”引脚、用于有源电缆的VCONN +5V电源,以及用于电缆方向检测和连接管理的通道配置 (CC) 引脚。请注意,在特定应用中引脚使用有所不同,具体取决于所采用的通信协议和功率传输要求(图1)。
USB Type-C和USB PD可通过可配置的电缆、接口和功率设置实现多功能性。USB Type-C连接器使用CC引脚进行电气检测和连接配置。USB Type-C端口可以作为仅主机、仅设备(以传统 USB 主机和设备运行)或双角色端口 (DRP);主机是下行端口 (DFP),设备是上行端口 (UFP)。
就这方面而言,STMicroelectronics推出了STEVAL-ISC004V1 USB PD EK。该EK是一款即用型USB PD源,基于该公司的STUSB4710A USB PD控制器,演示了如何将固定电压的直流电源输入转换为USB PD可变电压输出。USB PD控制器通过USB Type-C的CC引脚进行通信,以协调传输至连接设备的给定功率,无需微控制器支持即可处理与DFP或UFP的连接。