logo

snapshot时osError:failed to write requested bytes

2018-10-06 15:13
D
lg1h
ec5e394f-ba41-49fd-a6f2-89fd45c196c2.png

SD卡已插入。

请问是什么原因造成的?

I
网红小智智 星瞳科技

OpenMV 要在开机之前插入SD卡

D
lg1h

补充:代码为snapshot的例程

I
网红小智智 星瞳科技

请发具体的代码,图片不要用手机拍,根本看不清。

2018-10-06 15:27
D
lg1h
import sensor, image, pyb

RED_LED_PIN = 1
BLUE_LED_PIN = 3

sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.HQVGA) # or sensor.QQVGA (or others)
sensor.skip_frames(time = 2000) # Let new settings take affect.

# Load up a face detection HaarCascade. This is object that your OpenMV Cam
# can use to detect faces using the find_features() method below. Your OpenMV
# Cam has fontalface HaarCascade built-in. By default, all the stages of the
# HaarCascade are loaded. However, You can adjust the number of stages to speed
# up processing at the expense of accuracy. The frontalface HaarCascade has 25
# stages.
face_cascade = image.HaarCascade("frontalface", stages=25)

while(True):

    pyb.LED(RED_LED_PIN).on()
    print("About to start detecting faces...")
    sensor.skip_frames(time = 2000) # Give the user time to get ready.

    pyb.LED(RED_LED_PIN).off()
    print("Now detecting faces!")
    pyb.LED(BLUE_LED_PIN).on()

    diff = 10 # We'll say we detected a face after 10 frames.
    while(diff):
        img = sensor.snapshot()
        # Threshold can be between 0.0 and 1.0. A higher threshold results in a
        # higher detection rate with more false positives. The scale value
        # controls the matching scale allowing you to detect smaller faces.
        faces = img.find_features(face_cascade, threshold=0.5, scale_factor=1.5)

        if faces:
            diff -= 1
            for r in faces:
                img.draw_rectangle(r)

    pyb.LED(BLUE_LED_PIN).off()
    print("Face detected! Saving image...")
    sensor.snapshot().save("snapshot-%d.jpg" % pyb.rng()) # Save Pic.

前面运行正常,能框出人脸,最后一步报错,报错内容见标题
D
lg1h

@kidswong999 谢谢指导!前面试了一下,把电脑关机后我先插了SD卡,然后开电脑,最后连硬件,但问题依然存在,请问我的顺序正确吗?

I
网红小智智 星瞳科技

是先插SD卡,然后把OpenMV 插入电脑。然后在IDE里运行代码。

2018-10-06 15:47
D
lg1h

问题解决了,非常感谢!