RealOrangeOne / zoloto

A fiducial marker system powered by OpenCV - Supports ArUco and April
https://zoloto.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
13 stars 7 forks source link

Use VideoCaptureMixin as capture_frame implementation #221

Closed trickeydan closed 4 years ago

trickeydan commented 4 years ago

When the inheritance of classes is in any other order for Camera, it results in the abstract capture_frame implementation being used instead of the implementation in VideoCaptureMixin. This results in NotImplementedErrors whenever using either of these cameras. Interestingly, this is not caught by linting, typing or the runtime protections against executing abstractmethods.

Code to reproduce bug before this patch:

from zoloto.cameras import Camera
from zoloto.marker_type import MarkerType

class ZolotoCamera(Camera):

    marker_type = MarkerType.DICT_APRILTAG_36H11

    def get_marker_size(self, marker_id: int) -> int:
        return 80

cam = ZolotoCamera(0)

cam.capture_frame()

Possible inheritance orders:

RealOrangeOne commented 4 years ago

Nice catch! Yeah mixin inheritance here is fun.

Surprised abc and mypy didn't catch this, but hey least it's a pretty simple fix.

Looks like there are a couple other cameras which use the "incorrect" inheritance order, which I'd be interested in also addressing in this PR.

trickeydan commented 4 years ago

Looks like there are a couple other cameras which use the "incorrect" inheritance order, which I'd be interested in also addressing in this PR.

Sorted.