在做寻线小车时候,想把识别直线的过程录制下来,方便调参数,应该怎么添加录像。
http://book.openmv.cc/example/06-Video-Recording/mjpeg.html
# Image Writer Example
#
# USE THIS EXAMPLE WITH A USD CARD! Reset the camera after recording to see the file.
#
# This example shows how to use the Image Writer object to record snapshots of what your
# OpenMV Cam sees for later analysis using the Image Reader object. Images written to disk
# by the Image Writer object are stored in a simple file format readable by your OpenMV Cam.
THRESHOLD = (0, 35, -16, 13, -15, 23)
import sensor, image, pyb, time
from pyb import UART
record_time = 10000 # 10 seconds in milliseconds
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
uart = UART(3, 9600)
img_writer = image.ImageWriter("/stream.bin")
# Red LED on means we are capturing frames.
red_led = pyb.LED(1)
red_led.off()
start = pyb.millis()
while pyb.elapsed_millis(start) < record_time:
clock.tick()
#img = sensor.snapshot()
# Modify the image if you feel like here...
img = sensor.snapshot().binary([THRESHOLD])
line = img.get_regression([(100,100,0,0,0,0)], robust = True)
if (line):
img.draw_line(line.line(), color = 127)
if line.theta()>90:
theta_err = 270 - line.theta()
else:
theta_err = 90 - line.theta()
#print(line.magnitude(),line.theta(),line.rho())
img_data = bytearray([theta_err])
uart.write(img_data+'\r\n')
#led3.on()
print(theta_err,line.theta())
#print(clock.fps())
img_writer.add_frame(img)
print(clock.fps())
img_writer.close()
# Blue LED on means we are done.
red_led.off()
blue_led = pyb.LED(3)
blue_led.on()
#blue_led.off()
print("Done")
while(True):
clock.tick()
#img = sensor.snapshot()
# Modify the image if you feel like here...
img = sensor.snapshot().binary([THRESHOLD])
line = img.get_regression([(100,100,0,0,0,0)], robust = True)
if (line):
img.draw_line(line.line(), color = 127)
if line.theta()>90:
theta_err = 270 - line.theta()
else:
theta_err = 90 - line.theta()
#print(line.magnitude(),line.theta(),line.rho())
img_data = bytearray([theta_err])
uart.write(img_data+'\r\n')
#led3.on()
print(theta_err,line.theta())你代码的问题是什么?
录制下来的视频不能播放
你的代码不对,请运行我链接里面的代码。
您的代码里面只有录制视频,想要实现的功能是寻线的同时还要录制视频,在我播放这段视频的时候应该出现巡线的过程,视频中有巡线时出现的边框啊之类的一些东西,请问可以实现吗?谢谢。