- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using Realsense D435 with pyrealsense2 library. Programming in python and also using OpenCV, numpy libraries.
I rewrote the program in python for measuring distance. Link to source: https://github.com/IntelRealSense/librealsense#ready-to-hack
Code:
#Camera set up
while True:
frames = pipeline.wait_for_frames()
depth_frame = frames.get_depth_frame()
if not depth_frame: continue
width = depth_frame.get_width()
height = depth_frame.get_height()
#print(width,height)
#Calculate distance
dist_to_center = depth_frame.get_distance(int(width/2), int(height/2))
print('The camera is facing an object:',dist_to_center,'meters away')
it output the distance as expected. I hold a book in the center of the camera and it calculate that distance. see picture below
Result:
However, when i moved the book below, the distance is no longer calculated.
Result:
Currently it display distance to object at the center. I want the distance covering the whole image. how can i do this?
current:
calculates distance at this region (yellow box on the image above)
I want this:
I want the distance for whole image (if that make sense). If an object is closer to camera at right,left,above,below or center, I want to calculate distance to that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see.
Is there a way to get distance using just the depth.frame.get_distance() of the whole image stream?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello NeuroGalaxy, I saw your post well. I want to do the program you implemented now (I want to know the code that receives distance data in real time), could you please share the code with me?
From.SUNGDEOK
![](/skins/images/872293744008A34B36F8ABF94A46CC66/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page