|
139 | 139 | "metadata": {}, |
140 | 140 | "outputs": [], |
141 | 141 | "source": [ |
| 142 | + "send_alert_from_cam_ids = [2, 4, 5, 14] # select cameras\n", |
| 143 | + "\n", |
142 | 144 | "sequances_folders = glob.glob(f\"{SAMPLE_PATH}/*\")\n", |
143 | 145 | "\n", |
144 | 146 | "for camera_id in send_alert_from_cam_ids:\n", |
|
151 | 153 | " imgs.sort()\n", |
152 | 154 | " preds = glob.glob(f\"{sequances_folder}/labels_predictions/*\")\n", |
153 | 155 | " preds.sort()\n", |
154 | | - " \n", |
155 | | - " cam_center_azimuth = random.randint(0,360)\n", |
156 | | - " print(f\"Sending alerts from camera {camera_id} at azimuth {cam_center_azimuth}\")\n", |
| 156 | + "\n", |
| 157 | + " cam_poses = camera_client.get_current_poses().json()\n", |
| 158 | + " # pick a random pose id\n", |
| 159 | + " pose_id = random.choice(cam_poses)['id']\n", |
| 160 | + "\n", |
| 161 | + " print(f\"Sending alerts from camera {camera_id} at (pose_id={pose_id})\")\n", |
157 | 162 | " for img_file, pred_file in zip(imgs, preds):\n", |
158 | 163 | " \n", |
159 | 164 | " stream = io.BytesIO()\n", |
160 | 165 | " im = Image.open(img_file)\n", |
161 | 166 | " im.save(stream, format=\"JPEG\", quality=80)\n", |
162 | 167 | "\n", |
163 | 168 | " bboxes = read_pred_file(pred_file)\n", |
164 | | - " response = camera_client.create_detection(stream.getvalue(), cam_center_azimuth, bboxes)\n", |
| 169 | + " response = camera_client.create_detection(stream.getvalue(), bboxes, pose_id=pose_id)\n", |
165 | 170 | " # Force a KeyError if the request failed\n", |
166 | 171 | " \n", |
167 | 172 | " response.json()[\"id\"]" |
|
193 | 198 | "source": [ |
194 | 199 | "SEQUENCES_DIR_PATH = \"../data/alert_samples/single_sequences/*\"\n", |
195 | 200 | "sequences_directories = glob.glob(SEQUENCES_DIR_PATH)\n", |
196 | | - "CAM_MAPPING = {22:13, 42:7, 59:5, 14:11, 43:8, 79:14, 13:10, 11:15, 59:1, 60:2, 15:12, 12:9, 10:16, 41:2, 65:8}\n", |
| 201 | + "CAM_MAPPING = {22: 13, 42: 7, 59: 5, 14: 11, 43: 8, 79: 14, 13: 10, 11: 15, 60: 2, 15: 12, 12: 9, 10: 16, 41: 2, 65: 8}\n", |
197 | 202 | "\n", |
198 | 203 | "for seq_path in sequences_directories:\n", |
199 | 204 | " \n", |
|
211 | 216 | " preds = glob.glob(f\"{seq_path}/labels_predictions/*\")\n", |
212 | 217 | " preds.sort()\n", |
213 | 218 | "\n", |
214 | | - " cam_center_azimuth = random.randint(0,360)\n", |
| 219 | + " cam_poses = camera_client.get_current_poses().json()\n", |
| 220 | + " # pick a random pose id\n", |
| 221 | + " pose_id = random.choice(cam_poses)['id']\n", |
| 222 | + "\n", |
215 | 223 | " \n", |
216 | | - " print(f\"Sending alerts from camera {camera_id} at azimuth {cam_center_azimuth}\")\n", |
| 224 | + " print(f\"Sending alerts from camera {camera_id} at (pose_id={pose_id})\")\n", |
217 | 225 | " for img_file, pred_file in zip(imgs, preds):\n", |
218 | 226 | " \n", |
219 | 227 | " stream = io.BytesIO()\n", |
|
223 | 231 | " #bboxes = read_pred_file(pred_file)\n", |
224 | 232 | " with open(pred_file, 'r', encoding='utf-8') as file:\n", |
225 | 233 | " bboxes = ast.literal_eval(file.read())\n", |
226 | | - " \n", |
227 | 234 | " #bboxes = np.loadtxt(pred_file, ndmin=2)\n", |
228 | | - " response = camera_client.create_detection(stream.getvalue(), cam_center_azimuth, bboxes)\n", |
| 235 | + " response = camera_client.create_detection(stream.getvalue(), bboxes, pose_id=pose_id)\n", |
| 236 | + "\n", |
229 | 237 | " # Force a KeyError if the request failed\n", |
230 | 238 | " time.sleep(0.5)\n", |
231 | 239 | " response.json()[\"id\"]" |
|
352 | 360 | "name": "python", |
353 | 361 | "nbconvert_exporter": "python", |
354 | 362 | "pygments_lexer": "ipython3", |
355 | | - "version": "3.13.7" |
| 363 | + "version": "3.11.14" |
356 | 364 | } |
357 | 365 | }, |
358 | 366 | "nbformat": 4, |
|
0 commit comments