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

Rotating Cameras before they are put into the preview frame #8

Open
ReiVanBjair opened this issue Feb 13, 2020 · 6 comments
Open

Rotating Cameras before they are put into the preview frame #8

ReiVanBjair opened this issue Feb 13, 2020 · 6 comments

Comments

@ReiVanBjair
Copy link

The title says my problem, I am having a hard time rotating each camera before they are put into the frame. I tried setting stereo_mode into top-bottom and then rotating the whole frame itself but since the resolutions are mixed up I am seeing green statics

@realizator
Copy link
Owner

realizator commented Feb 13, 2020

Hi!
Try to set vertical flip.
As an example, you can look in the 1_test.py code, row 60:

camera.hflip = True

In your case you may try to use vflip this way:

camera.vflip = True

p.s. Please keep this camera settings in all your code (including calibration images capture and depth map)

@ReiVanBjair
Copy link
Author

Oh I need to rotate it by 90 degrees, hflip and vflip only allows you 180 degrees rotation.

@realizator
Copy link
Owner

Ough, 90 degree rotation is a problem in stereoscopic mode. I describe this issue in this article https://stereopi.com/blog/diy-vr-headset-stereopi-10-ms-latency-just-135 (search by "Problem #3" At this moment we use physical camera rotation.
If you're using this setup not for the user 3D view, but for OpenCV processing, you can capture stereoscopic pair with rotated images, and rotate each 90 degree after cut it on pairs and before processing.

@ReiVanBjair
Copy link
Author

If you're using this setup not for the user 3D view, but for OpenCV processing, you can capture stereoscopic pair with rotated images, and rotate each 90 degree after cut it on pairs and before processing.

Yeah this is what I'm doing right now, I just think that it'll be a bit disorienting for the would-be users if they are to adjust an object in a rotated preview before they can capture an image

It would be nice if we can just communicate with the registers in the camera directly. I've been looking on how to modify them so that they automatically rotate on their own, but I can't seem to find a way to change the values in the camera's register

@realizator
Copy link
Owner

Yeah this is what I'm doing right now, I just think that it'll be a bit disorienting for the would-be users if they are to adjust an object in a rotated preview before they can capture an image

That's why in our code we're not using native camera preview feature, but show already captured and processed images by means of Python's imshow. You can rotate images before showing them to the user.

It would be nice if we can just communicate with the registers in the camera directly. I've been looking on how to modify them so that they automatically rotate on their own, but I can't seem to find a way to change the values in the camera's register

Unfortunately, low-level RPi camera ecosystem is closed. I2C is occupied with the VPU system, and you can not access camera registers, if you want to use native applications like PiCamera or raspivid/raspistill etc. But you can access a registers if you 'll write your own driver, and this way you can access the video by, say, raspiraw or V4L. This is a hard way for experienced users.

@m-nawale
Copy link

m-nawale commented Jan 3, 2024

Hi, I have the same issue.
For my project, I am not using the mounting provided in stereopi kit. I had to design a custom mounting due to space restrictions.
mounting

Now, the left camera is rotated 90 degree anticlockwise and the right camera 90 degrees clockwise as the ribbions had to go through the center of the mounting.

Please suggest me the correct way.
I did following modifications to the 1_test.py given in the tutorial which is not working properly:

for frame in camera.capture_continuous(capture, format="bgra", use_video_port=True, resize=(img_width, img_height)):
counter+=1

img_width_1 = int (cam_width * scale_ratio / 2)

frame_left = frame[:, :img_width_1, :]
frame_right = frame[:, img_width_1:, :]

frame_left_clockwise = cv2.flip(cv2.transpose(frame_left), 0)
frame_right_anticlockwise = cv2.flip(cv2.transpose(frame_right), 1)

combined_frame = np.hstack((frame_left_clockwise, frame_right_anticlockwise))

 cv2.imshow("pair", combined_frame)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants