-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageDisplayServer.py
More file actions
32 lines (25 loc) · 866 Bytes
/
ImageDisplayServer.py
File metadata and controls
32 lines (25 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pyigtl
import cv2
import numpy as np
# Create a PyIGTLink server
port = 18939
server = pyigtl.OpenIGTLinkServer(port=port) # You can choose any available port
# Create a dictionary to store the last received image for each device name
image_data_dict = {}
# Start the server
server.start()
print(f'Image Display Server started on port {port}')
try:
while True:
# Accept incoming connections
message_RGB = server.wait_for_message("RGB_Image", timeout=1)
if message_RGB:
cv2.imshow("RGB", message_RGB.image)
message_Depth = server.wait_for_message("Depth_Image", timeout=1)
if message_Depth:
cv2.imshow("Depth", message_Depth.image)
cv2.waitKey(1)
except KeyboardInterrupt:
# Stop the server when Ctrl+C is pressed
server.stop()
cv2.destroyAllWindows()