{"record":{"id":"d5ba98c182ab2820","repo":"tensorflow/models","slug":"opencv-could-not-read-the-image-at-image-path-s","errorCode":null,"errorMessage":"OpenCV could not read the image at {image_path!s}. The file may be missing, corrupt, or in an unsupported format.","messagePattern":"OpenCV could not read the image at (.+?)\\. The file may be missing, corrupt, or in an unsupported format\\.","errorType":"exception","errorClass":"ImageReadError","httpStatus":null,"severity":"error","filePath":"official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/image_ops.py","lineNumber":60,"sourceCode":"  implementation. The two implementations are not bit-identical (PIL and\n  OpenCV use slightly different Lanczos filter parameters) but are visually\n  equivalent and produce nearly identical downstream detections.\n\n  Args:\n    image_path: Path to the image file on disk.\n    max_short_side: Maximum allowed length of the shortest side. If the image is\n      larger, it is downscaled preserving aspect ratio.\n\n  Returns:\n    The loaded and (optionally) resized image as a PIL RGB Image.\n\n  Raises:\n    ImageReadError: If OpenCV is unable to decode the file (missing, corrupt,\n      or unsupported format).\n  \"\"\"\n  bgr_image = cv2.imread(str(image_path))\n  if bgr_image is None:\n    raise ImageReadError(\n        f\"OpenCV could not read the image at {image_path!s}. The file may be \"\n        \"missing, corrupt, or in an unsupported format.\"\n    )\n  height, width = bgr_image.shape[:2]\n  new_width, new_height = _compute_resized_dimensions(\n      width=width, height=height, max_short_side=max_short_side\n  )\n  if (new_width, new_height) != (width, height):\n    bgr_resized = cv2.resize(\n        bgr_image,\n        (new_width, new_height),\n        interpolation=cv2.INTER_LANCZOS4,\n    )\n  else:\n    bgr_resized = bgr_image\n  rgb_resized = cv2.cvtColor(bgr_resized, cv2.COLOR_BGR2RGB)\n  return Image.fromarray(rgb_resized)\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/image_ops.py#L42-L78","documentation":"Error \"OpenCV could not read the image at {image_path!s}. The file may be missing, corrupt, or in an unsupported format.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/image_ops.py:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}