SensorsINI / v2e

V2E: From video frames to DVS events
https://sites.google.com/view/video2events/home
MIT License
274 stars 48 forks source link

I put different pictures together into a video and then ran v2e. There will be flickering during the transition. Is there any way to remove it? #69

Open 108360215 opened 1 month ago

108360215 commented 1 month ago

image

duguyue100 commented 1 month ago

v2e doesn't do any video smoothing given a video. Maybe do some post-processing before you produce the video? Use some kind of smoothing or stabilization from a video editor?

tobidelbruck commented 1 month ago

Could you be more clear about your setup?  Are the pictures from a video sequence? If so, is there aliasing in the video, i.e. is the frame rate too low to capture the highest frequencies?  If the spatial jumps are too large, then superslomo cannot compute optical flow.  Please share part of the video sequence.

108360215 commented 1 month ago

image I use like these non-continuous picture to combine the video, and this is my command :python v2e.py -i "D:\Downloads\VisDrone2019-VID-train\sequences\uav0000020_00406_v_output_video.avi" -o "D:\Downloads\VisDrone2019-VID-train\sequences\uav0000020_00406_v" --overwrite --unique_output_folder false --davis_output --dvs_h5 "events2.h5" --dvs_aedat2 "None" --dvs_text "None" --no_preview --input_frame_rate 24 --input_slowmotion_factor 1 --disable_slomo --auto_timestamp_resolution true --pos_thres 0.4 --neg_thres 0.4 --sigma_thres 0.03 --cutoff_hz 200 --leak_rate_hz 5.18 --shot_noise_rate_hz 2.716 --output_height=480 --output_width=640 --dvs_exposure duration .033 --dvs_params clean

and this is the code I use to combine the picture to video: import cv2 import os

def images_to_video(image_folder, video_path, fps=1): images = [img for img in os.listdir(image_folder) if img.endswith(".jpg")] images.sort() # 確保圖片按照順序合併

# 獲取第一張圖片的尺寸
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape

# 初始化影片寫入器
video = cv2.VideoWriter(video_path, cv2.VideoWriter_fourcc(*'DIVX'), fps, (width, height))

for image in images:
    img_path = os.path.join(image_folder, image)
    frame = cv2.imread(img_path)
    video.write(frame)

cv2.destroyAllWindows()
video.release()

使用範例

image_folder = 'D:\UAV-Vehicle-Detection-Dataset\train\test' video_path = 'D:\UAV-Vehicle-Detection-Dataset\train\output_video2.avi' images_to_video(image_folder, video_path, fps=1) # fps 可以根據需要調整

and I already choose some fps like1,5,24,30 on the v2e and images_to_video , they all will be like the previous picture(noise), so what do you guys think about. Thanks to help me solve this problem!!

duguyue100 commented 1 month ago

Do you know the original frame rate of these video frames? If it's a super low rate, the displacement between frames could be very large. In this case, you might want to remove the --disable-slomo option from the command to allow the SloMo model to interpolate some frames in between, otherwise, you will always get this kind of effect as the changes between pixels are very big.

108360215 commented 1 month ago

original frame rate depend what I set up, I tried to set up 30 before but still noise, I can try to use this --disable-slomo, but what do you think my output fps should be? also 30? And you say I can interpolate some frames in between, you mean when I combine the non continuous picture to video?

tobidelbruck commented 1 month ago

Based on a quick  look at your video sequence your bursty output is expected and v2e works "correctly". v2e is intended to realistically simulate DVS events resulting from continuous time video input. If you feed stroboscopic image sequences, the output will in your case is realistic: you are showing the "camera" a series of images which have big changes between them, as a result there will be huge bursts of events.   Or am I missing something?

108360215 commented 1 month ago

So I'm curious if there's a way to merge these different types of images into a video and then convert it to event data. Otherwise, I can only find continuous images to convert, which significantly limits the size of my dataset. What do you guys think about