Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ preprocessing/preprocessingImages/BestBFParameters/
preprocessing/preprocessingImages/images/
.vs/
machineLearning/Object-Classification-and-Detection/Keras-Sandbox/simple-image-classification-model/pyimagesearch/__pycache__/
depthSensing/images/
depthSensing/images/
19 changes: 16 additions & 3 deletions depthSensing/depth_sensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
########################################################################

import pyzed.sl as sl
from pixel_depth import depth_value
import math
import numpy as np
import sys
Expand Down Expand Up @@ -57,6 +58,7 @@ def main():
i = 0
image_zed = sl.Mat(img_size.width, img_size.height, sl.MAT_TYPE.U8_C4)
depth_img_zed = sl.Mat(img_size.width, img_size.height, sl.MAT_TYPE.U8_C4)
depth_val_zed = sl.Mat(img_size.width, img_size.height, sl.MAT_TYPE.U8_C4)
point_cloud = sl.Mat()

mirror_ref = sl.Transform()
Expand All @@ -69,13 +71,24 @@ def main():

# Retrieve left image and depth image
zed.retrieve_image(image_zed, sl.VIEW.LEFT, sl.MEM.CPU, img_size)
zed.retrieve_image(depth_img_zed, sl.VIEW.DEPTH, sl.MEM.CPU, img_size)
zed.retrieve_image(depth_img_zed, sl.VIEW.DEPTH, sl.MEM.CPU, img_size)
# Gives depth value at a certain pixel
# Test depth value at center pixel
## Add condition to determine when to use, or just remain the same ##
## Maybe get center value of bounding box(es) as the dimension w.r.t. the center of image ##
if True:
zed.retrieve_measure(depth_val_zed, sl.MEASURE.DEPTH, sl.MEM.CPU, img_size)
depth_val_ocv = depth_val_zed.get_data()
# For placeholder, gives value at the center of image
depth = depth_value(int(len(depth_val_ocv)/2), int(len(depth_val_zed[0])/2), depth_val_ocv)
print(depth)
# Retrieve colored point cloud. Point cloud is aligned on the left image.
zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA, sl.MEM.CPU)
zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA, sl.MEM.CPU)

# Retrieve images from matrices
# Retrive image Numpy array
img_ocv = image_zed.get_data()
depth_img_ocv = depth_img_zed.get_data()
# Load depth data into Numpy array

# Display what the camera sees
cv2.imshow("Image", img_ocv)
Expand Down
2 changes: 2 additions & 0 deletions depthSensing/pixel_depth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def depth_value(width, height, depth_meas):
return depth_meas[width][height]