-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
base: development
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
Using depth image to compute depth planes locally. | ||
|
||
|
||
Usage: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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% |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
I built a wrapper (attached) for RS Library that looks like OpenCV.
It also has extended functionality - output types, parameter configuration and etc...
I find it useful
________________________________
From: remibettan
Sent: Sunday, May 4, 2025 10:15 AM
To: IntelRealSense/librealsense
Cc: Dubin, Uri; Author
Subject: Re: [IntelRealSense/librealsense] Python applications for RealSense (PR #13647)
@remibettan commented on this pull request.
________________________________
In applications/shape_detector/src/plane_detector.py<#13647 (comment)>:
+Install :
+
+
+
+'''
+
+import numpy as np
+import cv2 as cv
+import unittest
+from scipy.spatial.transform import Rotation as Rot
+#from scipy import interpolate
+
+ # importing common Use modules
+import sys
+sys.path.append(r'..\Utils\src')
+from opencv_realsense_camera import RealSense
what is opencv_realsense_camera - is it a known package, or something you built in your env?
—
Reply to this email directly, view it on GitHub<#13647 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BJ6FGL3T3V4OWUDZJCJXXNL24W5CPAVCNFSM6AAAAABUOQPJLOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDQMJTGM4DANRQGI>.
You are receiving this because you authored the thread.
---------------------------------------------------------------------
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
|
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
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.