Skip to content

Commit

Permalink
Merge pull request #368 from OpenTrafficCam/Fix-OpenCvVideoReader-rea…
Browse files Browse the repository at this point in the history
…ding-bgr-instead-of-rgb-frame

bug/3309-opencvvideoreader-reads-bgr-instead-of-rgb-frame
  • Loading branch information
briemla committed Oct 13, 2023
2 parents 579415c + 7fd079a commit 7fc0e37
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions OTAnalytics/plugin_video_processing/video_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def get_frame(self, video_path: Path, index: int) -> TrackImage:
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
frame_to_load = min(index, (total_frames - 1))
cap.set(cv2.CAP_PROP_POS_FRAMES, frame_to_load)
is_read, frame = cap.read()
is_read, bgr_frame = cap.read()
cap.release()
return PilImage(Image.fromarray(frame).convert(GRAYSCALE))
rgb_frame = bgr_frame[:, :, ::-1]
return PilImage(Image.fromarray(rgb_frame).convert(GRAYSCALE))

@staticmethod
def __get_clip(video_path: Path) -> VideoCapture:
Expand Down

0 comments on commit 7fc0e37

Please sign in to comment.