Skip to content

Python applications for RealSense #13647

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

Open
wants to merge 47 commits into
base: development
Choose a base branch
from

Conversation

UD31415
Copy link

@UD31415 UD31415 commented Jan 1, 2025

The idea is to develop a high-level applications for the real sense camera.
Examples:
https://www.stereolabs.com/en-il/solutions/autonomous-robotics
https://github.com/stereolabs/zed-sdk
https://www.orbbec.com/
It is a draft with some preliminary code to test the submission process.

@sysrsbuild
Copy link
Collaborator

Can one of the admins verify this patch?

@Nir-Az Nir-Az requested a review from remibettan April 30, 2025 10:47
Using depth image to compute depth planes locally.


Usage:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove these lines, until the imports

import cv2 as cv
import unittest
from scipy.spatial.transform import Rotation as Rot
#from scipy import interpolate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove

# importing common Use modules
import sys
sys.path.append(r'..\Utils\src')
from opencv_realsense_camera import RealSense
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is opencv_realsense_camera - is it a known package, or something you built in your env?

class PlaneDetector:
def __init__(self):

self.frame_size = (640,480)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be sure that this resolution is available for the device - is there some check or some exception raised in case it is not available?

self.cam_distort= np.array([0,0,0,0,0],dtype = np.float32)

self.img3d = None # contains x,y and depth plains
self.imgXYZ = None # comntains X,Y,Z information after depth image to XYZ transform
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - contains

img_size = img_gray.size

# Set the percentage of pixels that should contain noise
#noise_percentage = 0.1 # Setting to 10%
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be uncommented?

img_noised = img_gray.copy()

# Create a noise list with random placements of min and max values of the image pixels.
#noise = np.random.choice([img_gray.min(), img_gray.max()], noise_size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check if the right line is uncommented and eventually add a comment to explain the -10, 10

self.img = cv.resize(self.img , dsize = self.frame_size)

elif img_type == 13:
self.img = cv.imread(r"C:\Data\Depth\Plane\image_ddd_000.png", cv.IMREAD_GRAYSCALE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the local paths must be replaced with remote ones

@UD31415
Copy link
Author

UD31415 commented May 4, 2025 via email

self.img = cv.imread(r"C:\Data\Depth\Plane\image_scl_000.png", cv.IMREAD_GRAYSCALE)
self.img = cv.resize(self.img , dsize = self.frame_size)

#self.img = np.uint8(self.img)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed?

"load the test case"
roi = [0,0,self.frame_size[0],self.frame_size[1]]
if test_type == 1:
roi = [310,230,330,250] # xlu, ylu, xrb, yrb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can a comment be added to give a hint to the reader about the meaning of various rois

y3d[ii] = v[ii]*z3d[ii] #/fy
z3d[ii] = z3d[ii]

#self.img3d = np.stack((u/fx,v/fy,z3d), axis = 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed?

y3d = self.img3d[:,:,1].copy() # v/f

# filter bad z values
#ii = np.logical_and(z3d > 1e-6 , np.isfinite(z3d))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed?
Please explain below value 15

if __name__ == '__main__':
#print(__doc__)

# import sys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if these comments can be used for developing, please add some comment


#unittest.main()
suite = unittest.TestSuite()
#suite.addTest(TestPlaneDetector("test_Convert"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain below commented lines or remove

pip install opencv-contrib-python
pip install scipy
pip install matplotlib
pip install pyrealsense2-2.55.10.6089-cp310-cp310-win_amd64.whl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please replace with pyrealsense2, without build number


<your path>\Envs\planes3d\Scripts\activate.bat

4. Installing realsense driver. For example, download pyrealsense2-2.55.10.089-cp310-cp310-win_amd64.whl:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please replace by pyrealsense2, without build number

Copy link
Contributor

@remibettan remibettan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments.
Please make sure that this app can be used from any pc.
Please also move the code to root/wrappers/python/examples, or explain the aim of the applications folder you want to add.

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

Successfully merging this pull request may close these issues.

3 participants