jssantander1992 commited on
Commit
a2ddb3e
·
verified ·
1 Parent(s): 5d978a0

Update handler.py

Browse files

updated handler to deliver pixel

Files changed (1) hide show
  1. handler.py +16 -8
handler.py CHANGED
@@ -33,11 +33,13 @@ class EndpointHandler:
33
  - 'file': Base64 encoded image
34
  - 'image': PIL Image object
35
  - 'visualization': Boolean flag to return visualization-friendly format (default: False)
 
 
36
  Returns:
37
  Dictionary containing the depth map and metadata
38
  """
39
  # Process input data
40
- print(data)
41
  if "url" in data:
42
  # Download image from URL
43
  response = requests.get(data["url"], stream=True)
@@ -84,6 +86,13 @@ class EndpointHandler:
84
  # Check if visualization is requested
85
  visualization = data.get("visualization", False)
86
 
 
 
 
 
 
 
 
87
  if visualization:
88
  # Convert depth map to a visualization-friendly format (grayscale image)
89
  # Create a figure and plot the depth map
@@ -107,15 +116,14 @@ class EndpointHandler:
107
  "format": "base64_png"
108
  }
109
  else:
110
-
111
-
112
  result = {
 
113
  # "depth": normalized_depth.tolist(),
114
- "depth": compressed_depth_base64,
115
- "depth_map": depth_map,
116
- "min_depth": float(depth_min),
117
- "max_depth": float(depth_max),
118
- "shape": list(normalized_depth.shape)
119
  }
120
 
121
  return result
 
33
  - 'file': Base64 encoded image
34
  - 'image': PIL Image object
35
  - 'visualization': Boolean flag to return visualization-friendly format (default: False)
36
+ - 'x': Int pixel position on axis x
37
+ - 'y': Int pixel position on axis y
38
  Returns:
39
  Dictionary containing the depth map and metadata
40
  """
41
  # Process input data
42
+
43
  if "url" in data:
44
  # Download image from URL
45
  response = requests.get(data["url"], stream=True)
 
86
  # Check if visualization is requested
87
  visualization = data.get("visualization", False)
88
 
89
+ # Check the pixels to return if no pixel provided will return the [0,0] position
90
+ x= data.get('x',0)
91
+ y= data.get('y',0)
92
+
93
+ map = np.array(depth_map)
94
+ print(map.shape)
95
+
96
  if visualization:
97
  # Convert depth map to a visualization-friendly format (grayscale image)
98
  # Create a figure and plot the depth map
 
116
  "format": "base64_png"
117
  }
118
  else:
 
 
119
  result = {
120
+ "deph": depth_map[x][y]
121
  # "depth": normalized_depth.tolist(),
122
+ # "depth": compressed_depth_base64,
123
+ # "depth_map": depth_map,
124
+ # "min_depth": float(depth_min),
125
+ # "max_depth": float(depth_max),
126
+ # "shape": list(normalized_depth.shape)
127
  }
128
 
129
  return result