舵机不动
如果不知道怎么接的话。
用传感器扩展板插入OpenMV
https://singtown.com/product/49896/openmv-sensor-shield/
舵机引脚部分插入舵机。
DC接口插入电池
调用外部中断时出现memory allocation failed, heap is locked?
这样还是不行呀
from pyb import Pin, ExtInt
import sensor, image, time,pyb,micropython
micropython.alloc_emergency_exception_buf(100)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
def callback(line):
global ExtInt
ExtInt.disable()
print("line =", line)
ExtInt.enable()
extint = pyb.ExtInt(Pin('P0'), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, callback)
while(True):
clock.tick()
img = sensor.snapshot()
单独舵机测试代码可以控制舵机运动, 而加入其它语句就不行了
import sensor, image, time
import pyb
import car
from pyb import Pin, Timer,Servo
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(10)
sensor.set_auto_whitebal(False)
clock = time.clock()
green_threshold = (85, 42, 15, 58, 68, 31)
size_threshold = 2000
K=460
i=0
s3 = Servo(3) # P9
s3.angle(45)
time.sleep(1000)
s3.angle(-45)
time.sleep(1000)
我想把图片的每一个像素点RGB值都读取出来,通过串口发送出去,但是执行for循环这里非常缓慢,这是什么情况?
# Untitled - By: Administrator - 周二 一月 21 2020
import sensor, image, time
sensor.reset() #初始化相机传感器。
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
for A in range(0,240,1):
for B in range(0,320,1):
C=(img.get_pixel(A,B))
print(clock.fps())
openmv控制270度20kg舵机,为啥不能控制负角度?然后参数和转动角度是1比1.5的关系,这是为啥?
import time
from pyb import Servo
import sensor, image, time
from pyb import UART
#导入需要的模块
s1 = Servo(1) # P7
s2 = Servo(2) # P8
s3 = Servo(3) # P9
s3.angle(0)
time.sleep_ms(1000)
s1.angle(0)
time.sleep_ms(1000)
s2.angle(10)
time.sleep_ms(1000)
s2.angle(-10)
time.sleep_ms(1000)
请教一下运行方面的问题?
点运行一直显示这个
这是输入,有什么问题吗?
import sensor, time, image, pyb, tf, os, math
from pyb import UART
from pid import PID
from pyb import Servo
教程的人脸识别代码识别不了
import sensor, time, image
sensor.reset()
sensor.set_contrast(3)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)
clock = time.clock()
while (True):
clock.tick()
img = sensor.snapshot()
objects = img.find_features(face_cascade, threshold=0.75, scale=1.35)
#在找到的目标上画框,标记出来
for r in objects:
img.draw_rectangle(r)
如何写代码去检测摄像头是否有故障?比如拔掉摄像头,程序可以检测到该故障。
如题。如何在程序里用代码检测到摄像头拔掉了,返回并打印。而不是现在拔掉摄像头程序中sensor函数会报超时错误,程序就结束了。
怎么修改这个二维码的程序使二维码的内容在LCD中显示(纯小白,请大佬揉碎了喂嘴里)
@ztrp 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)
定时器问题,导致程序运行时突然卡死,为什么?
import sensor, image, time
from pyb import Pin, Timer
sensor.reset() # Reset and initialize the sensor.
#初始化摄像头,reset()是sensor模块里面的函数
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
#设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
#设置图像像素大小,sensor.QQVGA: 160x120,sensor.QQVGA2: 128x160 (一般用于LCD
#扩展板),sensor.QVGA: 320x240,sensor.VGA: 640x480, sensor.QQCIF: 88x72,sensor.QCIF: 176x144,sensor.CIF: 352x288
sensor.skip_frames(time = 2000) # Wait for settings take effect.
clock = time.clock()
def tick(timer): # we will receive the timer object when being called
print("Timer callback")
tim = Timer(4, freq=1) # create a timer object using timer 4 - trigger at 1Hz
tim.callback(tick) # set the callback to our tick function
while (True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
#截取当前图像,存放于变量img中。注意python中的变量是动态类型,不需要声明定义,直接用即可。
#print(clock.fps())
请在这里粘贴代码