Skip to content

Commit

Permalink
Works with v2 camera
Browse files Browse the repository at this point in the history
  • Loading branch information
brickbots committed Nov 6, 2024
1 parent 2bc1195 commit bdfbb4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/PiFinder/camera_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(self) -> None:
pass

def capture(self) -> Image.Image:
return Image.Image(), None
return Image.Image()

def capture_file(self, filename) -> None:
pass
Expand Down
12 changes: 7 additions & 5 deletions python/PiFinder/camera_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,27 @@ def capture(self) -> Image.Image:
"""
_request = self.camera.capture_request()
raw_capture = _request.make_array("raw")
# tmp_image = _request.make_image("main")
_request.release()
if self.camera_type == "imx296":
# Sensor orientation is different
# crop to square and resample to 16 bit from 2 8 bit entries
raw_capture = raw_capture.copy().view(np.uint16)[:, 184:-184]
# Sensor orientation is different
raw_capture = np.rot90(raw_capture, 2)
else:
# For OG camera type, the array needs to be converted
# from RGB to L. Easiest way to do this is just to
# add the flux from all the channels
raw_capture = np.sum(raw_capture, axis=[0, 1])
# crop to square and resample to 16 bit from 2 8 bit entries
raw_capture = raw_capture.copy().view(np.uint16)[:, 256:-256]

raw_capture = raw_capture.astype(np.float32)
max_pixel = np.max(raw_capture)

# if the whitepoint is already below 255, just cast it
# as we don't want to create fake in-between values
if max_pixel < 255:
raw_capture = raw_capture.astype(np.uint8)
else:
raw_capture = (raw_capture / max_pixel * 255).astype(np.uint8)

raw_image = Image.fromarray(raw_capture).resize((512, 512))
return raw_image

Expand Down

0 comments on commit bdfbb4a

Please sign in to comment.