clock = time.clock() curDir = uos.ilistdir() iMax = 0 tagFileName = 'img' for i in curDir: if i[1] == 0x8000: fileName = i[0] #print(fileName[0:5]) if fileName[0:3] == tagFileName: if int(fileName[3:-4]) >= iMax: iMax = int(fileName[3:-4]) + 1 streamFileName = tagFileName + str(iMax) + '.bin' img_writer = image.ImageWriter(streamFileName) # create a directory to hold images try: uos.mkdir("/imgs") except OSError: print("path '/imgs' already existed.") # Red LED on means we are capturing frames. # red_led = pyb.LED(1) # red_led.on() tag = 1 jMax = 0 # tagImgName = 'stream' start = pyb.millis()
sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) #sensor.set_pixformat(sensor.YUV422) # Set pixel format YUV422, test ok, slower than RGB565 sensor.set_framesize(sensor.VGA) sensor.set_hmirror(1) #for unit V #bugs?? sensor.set_vflip(1) #for unit V img_w = sensor.width() img_h = sensor.height() print("image sensor is " + str(sensor_ID_str) + ", with size " + str(img_w) + " x " + str(img_h)) sensor.skip_frames(time=1000) # Wait for settings take effect. #sensor.skip_frames(30) #Wait for settings take effect. if (MJPG_mode): #import gif movie = image.ImageWriter("/sd/rawmoviestream/movie_stream.bin") #movie = mjpeg.Mjpeg("/sd/rawautosave/example_movie.mjpeg") clock = time.clock() # Create a clock object to track the FPS. gc.collect() Zeit_end = 600 * 1000 condition = True Zeit_Anfang = time.ticks_ms() run_cnt = 0 loop_time = 1 fps = 0 Zeit_interval = 10 #10s Zeit_passed = Zeit_Anfang auto_gain_EN = True gain = 0 # 0 to 32? 8x max DR EXPO_us = 0
# # 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. import sensor, image, pyb, time record_time = 10000 # 10 seconds in milliseconds sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time=2000) clock = time.clock() img_writer = image.ImageWriter("/stream.bin") # Red LED on means we are capturing camera. red_led = pyb.LED(1) red_led.on() start = pyb.millis() while pyb.elapsed_millis(start) < record_time: clock.tick() img = sensor.snapshot() # Modify the image if you feel like here... img_writer.add_frame(img) print(clock.fps()) img_writer.close()