color event in python

32 views
Skip to first unread message

Jason Wu

unread,
Mar 5, 2024, 2:59:16 AMMar 5
to dv-users
I notice that in DV software, events are presented in green - red color mode. However, I failed to get such events in a python script. Moreover, existing color mode in docs are in a white background, which is different from what is in the software, a black one. I tried to read API but it's a CPP version. Here is the code. It's just the one from the website.
```
# Open the camera
camera = dv.io.CameraCapture()
camera.setDavisColorMode(dv.io.CameraCapture.DavisColorMode.Color)


# Initialize visualizer instance which generates event data preview
visualizer = dv.visualization.EventVisualizer(camera.getEventResolution())

# Create the preview window
cv.namedWindow("Preview", cv.WINDOW_NORMAL)


def preview_events(event_slice):
cv.imshow("Preview", visualizer.generateImage(event_slice))
cv.waitKey(2)


# Create an event slicer, this will only be used events only camera
slicer = dv.EventStreamSlicer()
slicer.doEveryTimeInterval(datetime.timedelta(milliseconds=33), preview_events)

# start read loop
while True:
# Get events
events = camera.getNextEventBatch()

# If no events arrived yet, continue reading
if events is not None:
slicer.accept(events)
```

Jason Wu

unread,
Mar 7, 2024, 11:53:34 AMMar 7
to dv-users
I've solved this problem. In class visualizer, there are methods to set background, positive and negative colors. Besides, I think modules on DV software can be confusing since events can be directly showed on UI while visualizer actually works.
Reply all
Reply to author
Forward
0 new messages