matrice-analytics 0.1.32__py3-none-any.whl → 0.1.34__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of matrice-analytics might be problematic. Click here for more details.

@@ -90,7 +90,7 @@ class FacialRecognitionClient:
90
90
  self.server_base_url = f"http://localhost:{server_port}"
91
91
  self.logger.warning(f"Server host matches public IP, using localhost: {self.server_base_url}")
92
92
  else:
93
- self.server_base_url = f"https://{server_host}:{server_port}"
93
+ self.server_base_url = f"http://{server_host}:{server_port}"
94
94
  self.logger.warning(f"Facial recognition server base URL: {self.server_base_url}")
95
95
 
96
96
  self.session.update(self.server_info.get('projectID', ''))
@@ -29,6 +29,7 @@ import logging
29
29
  import asyncio
30
30
  import urllib
31
31
  import urllib.request
32
+ import base64
32
33
  # Get the major and minor version numbers
33
34
  major_version = sys.version_info.major
34
35
  minor_version = sys.version_info.minor
@@ -285,8 +286,17 @@ class LicensePlateMonitorLogger:
285
286
  self.logger.warning(f"Failed to parse timestamp '{timestamp}': {e}. Using current time.")
286
287
  return datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
287
288
 
288
- async def log_plate(self, plate_text: str, timestamp: str, stream_info: Dict[str, Any], cooldown: float = 30.0) -> bool:
289
- """Log plate to RPC server with cooldown period."""
289
+ async def log_plate(self, plate_text: str, timestamp: str, stream_info: Dict[str, Any],
290
+ image_data: Optional[str] = None, cooldown: float = 30.0) -> bool:
291
+ """Log plate to RPC server with cooldown period.
292
+
293
+ Args:
294
+ plate_text: The license plate text
295
+ timestamp: Capture timestamp
296
+ stream_info: Stream information dict
297
+ image_data: Base64-encoded JPEG image of the license plate crop
298
+ cooldown: Cooldown period in seconds
299
+ """
290
300
  self.logger.info(f"Attempting to log plate: {plate_text} at {timestamp}")
291
301
 
292
302
  # Check cooldown
@@ -312,12 +322,13 @@ class LicensePlateMonitorLogger:
312
322
  'location': location,
313
323
  'camera': camera_name,
314
324
  'captureTimestamp': rfc3339_timestamp,
315
- 'projectId': project_id
325
+ 'projectId': project_id,
326
+ 'imageData': image_data if image_data else ""
316
327
  }
317
328
 
318
329
  # Add projectId as query parameter
319
330
  endpoint = f'/v1/lpr-server/detections?projectId={project_id}'
320
- self.logger.info(f"Sending POST request to {self.server_base_url}{endpoint} with payload: {payload}")
331
+ self.logger.info(f"Sending POST request to {self.server_base_url}{endpoint} with plate: {plate_text}, imageData length: {len(image_data) if image_data else 0}")
321
332
 
322
333
  response = await self.session.rpc.post_async(endpoint, payload=payload, base_url=self.server_base_url)
323
334
 
@@ -450,7 +461,7 @@ class LicensePlateMonitorUseCase(BaseProcessor):
450
461
  self._logging_enabled = False
451
462
 
452
463
  def _log_detected_plates(self, detections: List[Dict[str, Any]], config: LicensePlateMonitorConfig,
453
- stream_info: Optional[Dict[str, Any]]) -> None:
464
+ stream_info: Optional[Dict[str, Any]], image_bytes: Optional[bytes] = None) -> None:
454
465
  """Log all detected plates to RPC server with cooldown."""
455
466
  if not self._logging_enabled or not self.plate_logger or not stream_info:
456
467
  return
@@ -458,6 +469,24 @@ class LicensePlateMonitorUseCase(BaseProcessor):
458
469
  # Get current timestamp
459
470
  current_timestamp = self._get_current_timestamp_str(stream_info, precision=True)
460
471
 
472
+ # Encode the full frame image as base64 JPEG
473
+ image_data = ""
474
+ if image_bytes:
475
+ try:
476
+ # Decode image bytes
477
+ image_array = np.frombuffer(image_bytes, np.uint8)
478
+ image = cv2.imdecode(image_array, cv2.IMREAD_COLOR)
479
+
480
+ if image is not None:
481
+ # Encode as JPEG with 85% quality
482
+ success, jpeg_buffer = cv2.imencode('.jpg', image, [cv2.IMWRITE_JPEG_QUALITY, 99])
483
+ if success:
484
+ # Convert to base64
485
+ image_data = base64.b64encode(jpeg_buffer.tobytes()).decode('utf-8')
486
+ self.logger.debug(f"Encoded frame image as base64, length: {len(image_data)}")
487
+ except Exception as e:
488
+ self.logger.error(f"Failed to encode frame image: {e}")
489
+
461
490
  # Collect all unique plates from current detections
462
491
  plates_to_log = set()
463
492
  for det in detections:
@@ -479,6 +508,7 @@ class LicensePlateMonitorUseCase(BaseProcessor):
479
508
  plate_text=plate_text,
480
509
  timestamp=current_timestamp,
481
510
  stream_info=stream_info,
511
+ image_data=image_data,
482
512
  cooldown=config.plate_log_cooldown
483
513
  )
484
514
  tasks.append(task)
@@ -606,7 +636,7 @@ class LicensePlateMonitorUseCase(BaseProcessor):
606
636
  self._update_plate_texts(processed_data)
607
637
 
608
638
  # Step 9.5: Log detected plates to RPC (optional, only if lpr_server_id is provided)
609
- self._log_detected_plates(processed_data, config, stream_info)
639
+ self._log_detected_plates(processed_data, config, stream_info, input_bytes)
610
640
 
611
641
  # Step 10: Update frame counter
612
642
  self._total_frame_counter += 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice_analytics
3
- Version: 0.1.32
3
+ Version: 0.1.34
4
4
  Summary: Common server utilities for Matrice.ai services
5
5
  Author-email: "Matrice.ai" <dipendra@matrice.ai>
6
6
  License-Expression: MIT
@@ -30,7 +30,7 @@ matrice_analytics/post_processing/face_reg/__init__.py,sha256=yntaiGlW9vdjBpPZQX
30
30
  matrice_analytics/post_processing/face_reg/compare_similarity.py,sha256=NlFc8b2a74k0PqSFAbuM_fUbA1BT3pr3VUgvSqRpJzQ,23396
31
31
  matrice_analytics/post_processing/face_reg/embedding_manager.py,sha256=qbh0df3-YbE0qvFDQvjpCg-JrsCZRJ5capjQ2LPOj1k,35619
32
32
  matrice_analytics/post_processing/face_reg/face_recognition.py,sha256=17RVs_5BtGw2ruksL2JLbpXljbs4-96tP-yKGX3hrOI,90232
33
- matrice_analytics/post_processing/face_reg/face_recognition_client.py,sha256=jPssMC_UuKn8M-9IaTirP-aswpcTiYV5vdTImt6lt4Q,27576
33
+ matrice_analytics/post_processing/face_reg/face_recognition_client.py,sha256=YaC73mN0yrHZYkjJ7nZIZen5YCVOwEX2gn6I1XpHTW0,27575
34
34
  matrice_analytics/post_processing/face_reg/people_activity_logging.py,sha256=NhJXy9jCy_mlZiDXv8IeGyrRN_TL0kKCe3ZOlaNbZUw,13676
35
35
  matrice_analytics/post_processing/ocr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  matrice_analytics/post_processing/ocr/easyocr_extractor.py,sha256=FwVoUATYdiZtfhSAoiyCo_9dgA786pFZfONx6tsQOfE,11403
@@ -126,7 +126,7 @@ matrice_analytics/post_processing/usecases/leaf.py,sha256=cwgB1ZNxkQFtkk-thSJrkX
126
126
  matrice_analytics/post_processing/usecases/leaf_disease.py,sha256=bkiLccTdf4KUq3he4eCpBlKXb5exr-WBhQ_oWQ7os68,36225
127
127
  matrice_analytics/post_processing/usecases/leak_detection.py,sha256=oOCLLVMuXVeXPHyN8FUrD3U9JYJJwIz-5fcEMgvLdls,40531
128
128
  matrice_analytics/post_processing/usecases/license_plate_detection.py,sha256=dsavd92-wnyXCNrCzaRj24zH7BVvLSa09HkYsrOXYDM,50806
129
- matrice_analytics/post_processing/usecases/license_plate_monitoring.py,sha256=h4RHX9HXR6W0eQfFE1G6FRygvlmZQAWN3H323FWqvlQ,75268
129
+ matrice_analytics/post_processing/usecases/license_plate_monitoring.py,sha256=UaceT9ieQUjj1WRwtXkqmoNloG1Jc055u2AW2LvM8Eo,76747
130
130
  matrice_analytics/post_processing/usecases/litter_monitoring.py,sha256=XaHAUGRBDJg_iVbu8hRMjTR-5TqrLj6ZNCRkInbzZTY,33255
131
131
  matrice_analytics/post_processing/usecases/mask_detection.py,sha256=L_s6ZiT5zeXG-BsFcskb3HEG98DhLgqeMSDmCuwOteU,41501
132
132
  matrice_analytics/post_processing/usecases/natural_disaster.py,sha256=ehxdPBoYcZWGVDOVn_mHFoz4lIE8LrveAkuXQj0n9XE,44253
@@ -188,8 +188,8 @@ matrice_analytics/post_processing/utils/format_utils.py,sha256=UTF7A5h9j0_S12xH9
188
188
  matrice_analytics/post_processing/utils/geometry_utils.py,sha256=BWfdM6RsdJTTLR1GqkWfdwpjMEjTCJyuBxA4zVGKdfk,9623
189
189
  matrice_analytics/post_processing/utils/smoothing_utils.py,sha256=78U-yucAcjUiZ0NIAc9NOUSIT0PWP1cqyIPA_Fdrjp0,14699
190
190
  matrice_analytics/post_processing/utils/tracking_utils.py,sha256=rWxuotnJ3VLMHIBOud2KLcu4yZfDp7hVPWUtNAq_2xw,8288
191
- matrice_analytics-0.1.32.dist-info/licenses/LICENSE.txt,sha256=_uQUZpgO0mRYL5-fPoEvLSbNnLPv6OmbeEDCHXhK6Qc,1066
192
- matrice_analytics-0.1.32.dist-info/METADATA,sha256=zSaINlI-8xwx56Oc1aLW6qnbechmTBUIp1ZLZ0mKqJQ,14378
193
- matrice_analytics-0.1.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
194
- matrice_analytics-0.1.32.dist-info/top_level.txt,sha256=STAPEU-e-rWTerXaspdi76T_eVRSrEfFpURSP7_Dt8E,18
195
- matrice_analytics-0.1.32.dist-info/RECORD,,
191
+ matrice_analytics-0.1.34.dist-info/licenses/LICENSE.txt,sha256=_uQUZpgO0mRYL5-fPoEvLSbNnLPv6OmbeEDCHXhK6Qc,1066
192
+ matrice_analytics-0.1.34.dist-info/METADATA,sha256=KZrHth0YkNGwzjdc9O36coURdXHAGlfltJbkZ7PEz5Y,14378
193
+ matrice_analytics-0.1.34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
194
+ matrice_analytics-0.1.34.dist-info/top_level.txt,sha256=STAPEU-e-rWTerXaspdi76T_eVRSrEfFpURSP7_Dt8E,18
195
+ matrice_analytics-0.1.34.dist-info/RECORD,,