MCPcopy Create free account
hub / github.com/ARM-software/AVH / __convertFromBGR

Method __convertFromBGR

interface/vstream/python/vsi_video_server.py:479–513  ·  view source on GitHub ↗

Convert the input BGR frame to the specified color space if needed. Args: frame: The input frame (as NumPy array in BGR color space) to be converted. Returns: frame: The converted frame in the specified color space.

(self, frame)

Source from the content-addressed store, hash-verified

477 return frame
478
479 def __convertFromBGR(self, frame):
480 """
481 Convert the input BGR frame to the specified color space if needed.
482
483 Args:
484 frame: The input frame (as NumPy array in BGR color space) to be converted.
485 Returns:
486 frame: The converted frame in the specified color space.
487 """
488 if self.frame_color == self.RGB888:
489 # Convert BGR to RGB
490 logger.debug(f"__convertFromBGR: converting frame from BGR to RGB")
491 frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
492 elif self.frame_color == self.GRAYSCALE8:
493 # Convert BGR to Grayscale
494 logger.debug(f"__convertFromBGR: converting frame from BGR to Grayscale")
495 frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
496 elif self.frame_color == self.BGR565:
497 # Convert BGR to BGR565
498 logger.debug(f"__convertFromBGR: converting frame from BGR to BGR565")
499 frame = cv2.cvtColor(frame, cv2.COLOR_BGR2BGR565)
500 elif self.frame_color == self.YUV420:
501 # Convert BGR to YUV420
502 logger.debug(f"__convertFromBGR: converting frame from BGR to YUV420")
503 frame = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV_I420)
504 elif self.frame_color == self.NV12:
505 # Convert BGR to NV12
506 logger.debug(f"__convertFromBGR: converting frame from BGR to NV12")
507 frame = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV_NV12)
508 elif self.frame_color == self.NV21:
509 # Convert BGR to NV21
510 logger.debug(f"__convertFromBGR: converting frame from BGR to NV21")
511 frame = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV_NV21)
512
513 return frame
514
515 # Read frame from source
516 def _readFrame(self):

Callers 1

_readFrameMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected