Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync libcontroller develop #550

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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