Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 577173b
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Thu Dec 8 10:30:54 2022 +0100

    Sync submodule (cyberbotics#551)

    Co-authored-by: ad-daniel <[email protected]>

commit 1d65ba6
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Mon Dec 5 09:37:16 2022 +0100

    Sync submodule (cyberbotics#549)

    Co-authored-by: ad-daniel <[email protected]>

commit 324046f
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Thu Dec 1 09:47:07 2022 +0100

    Sync submodule (cyberbotics#546)

    Co-authored-by: ad-daniel <[email protected]>
  • Loading branch information
Inogec committed Dec 12, 2022
1 parent db7fb8f commit c70f888
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ def model(self) -> str:


class Camera(Sensor):
wb.wb_camera_get_image.restype = ctypes.POINTER(ctypes.c_ubyte)
wb.wb_camera_recognition_get_segmentation_image.restype = ctypes.POINTER(ctypes.c_ubyte)
wb.wb_camera_get_fov.restype = ctypes.c_double
wb.wb_camera_get_exposure.restype = ctypes.c_double
wb.wb_camera_get_focal_distance.restype = ctypes.c_double
Expand All @@ -78,6 +76,10 @@ def __init__(self, name: Union[str, int], sampling_period: int = None):
self._enable = wb.wb_camera_enable
self._get_sampling_period = wb.wb_camera_get_sampling_period
super().__init__(name, sampling_period)
width = self.width
height = self.height
wb.wb_camera_get_image.restype = ctypes.POINTER(ctypes.c_ubyte * (4 * width * height))
wb.wb_camera_recognition_get_segmentation_image.restype = ctypes.POINTER(ctypes.c_ubyte * (4 * width * height))

def getExposure(self) -> float:
return self.exposure
Expand All @@ -95,7 +97,7 @@ def getHeight(self) -> int:
return self.height

def getImage(self) -> bytes:
return bytes(self.image[:self.width * self.height * 4])
return self.image

def getImageArray(self) -> List[List[List[int]]]:
array = []
Expand Down Expand Up @@ -158,12 +160,12 @@ def setFov(self, f: float):
self.fov = f

@property
def image(self):
return wb.wb_camera_get_image(self._tag)
def image(self) -> bytes:
return bytes(wb.wb_camera_get_image(self._tag).contents)

@property
def segmentation_image(self):
return wb.wb_camera_recognition_get_segmentation_image(self._tag)
def segmentation_image(self) -> bytes:
return bytes(wb.wb_camera_recognition_get_segmentation_image(self._tag).contents)

@property
def exposure(self) -> float:
Expand Down Expand Up @@ -254,7 +256,7 @@ def isRecognitionSegmentationEnabled(self) -> bool:
return wb.wb_camera_recognition_is_segmentation_enabled(self._tag) != 0

def getRecognitionSegmentationImage(self) -> bytes:
return bytes(self.segmentation_image[:self.width * self.height * 4])
return self.segmentation_image

def getRecognitionSegmentationImageArray(self) -> List[List[List[int]]]:
array = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def getCount(self) -> int:
return self.count

def enableSFTracking(self, samplingPeriod: int):
wb.wb_supervisor_field_enable_sf_tracking(samplingPeriod)
wb.wb_supervisor_field_enable_sf_tracking(self._ref, samplingPeriod)

def disableSFTracking(self):
wb.wb_supervisor_field_disable_sf_tracking()
wb.wb_supervisor_field_disable_sf_tracking(self._ref)

def getSFBool(self) -> bool:
return self.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def simulation_mode(self) -> int:
return wb.wb_supervisor_simulation_get_mode()

@simulation_mode.setter
def mode(self, mode: int):
def simulation_mode(self, mode: int):
return wb.wb_supervisor_simulation_set_mode(mode)


Expand Down

0 comments on commit c70f888

Please sign in to comment.