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
13 changes: 12 additions & 1 deletion src/GUI_main_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ def __init__(self):
help_menu.addAction(help_action)
help_action.triggered.connect(self.open_help_window)

# Camera Combo Box
# Make default camera 0: Intel Realsense,1:oakDLite etc.
self.Select3DCamera.setCurrentIndex(0)
self.Select3DCamera.currentTextChanged.connect(self.on_camera_selected)

# Folder Options Hidden
self.folder_list.setHidden(True) # List of folders to put the data into
self.folder_name.setHidden(True)
Expand Down Expand Up @@ -297,6 +302,10 @@ def camera_options(self):
if os.path.isfile(f"{cwd}/cam_img_2.png"):
os.remove(f"{cwd}/cam_img_2.png")
'''
# Function to handle camera selection
def on_camera_selected(self, Select3DCamera):
self.Select3DCamera = Select3DCamera
print(Select3DCamera)

def open_help_window(self):
self.help_window = HelpWindow()
Expand Down Expand Up @@ -456,6 +465,7 @@ def define_objects_shown(self):


def color_button_pressed(self):

self.tracking_info = tracking(types_of_streams_saved = 'cd',
type_of_tracking = 'color',
input_folder = 'color_i',
Expand Down Expand Up @@ -965,6 +975,7 @@ def run_tracker(self):
image, color_ranges, min_radius_object, data_output_folder_path = self.get_settings()
# config by looking at the camera (remove this from tracking program below)
# find output folder here instead of
print(self.Select3DCamera)
if self.tracking_info.types_of_streams_saved =='cd':
# The color and depth streams need to be aligned for each frame slowing the tracking down
pipeline = find_and_config_device()
Expand All @@ -975,7 +986,7 @@ def run_tracker(self):
# The infrared and depth streams are already aligned
# object tracking at either 90 or 300 frames per second with infrared
pipeline, config = find_and_config_device_mult_stream(self.tracking_info.types_of_streams_saved)
pipeline.start(config)

GUI_obj_tracking(pipeline, image, color_ranges, min_radius_object, data_output_folder_path, self.tracking_info)


Expand Down
50 changes: 25 additions & 25 deletions src/tracker/lib/GUI_Base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ Select the additional variables you would like graphed</string>
<property name="geometry">
<rect>
<x>100</x>
<y>380</y>
<y>410</y>
<width>371</width>
<height>181</height>
</rect>
Expand Down Expand Up @@ -594,7 +594,7 @@ Select the additional variables you would like graphed</string>
<property name="geometry">
<rect>
<x>100</x>
<y>350</y>
<y>360</y>
<width>101</width>
<height>20</height>
</rect>
Expand All @@ -610,7 +610,7 @@ Select the additional variables you would like graphed</string>
<property name="geometry">
<rect>
<x>200</x>
<y>350</y>
<y>360</y>
<width>131</width>
<height>20</height>
</rect>
Expand All @@ -623,7 +623,7 @@ Select the additional variables you would like graphed</string>
<property name="geometry">
<rect>
<x>100</x>
<y>380</y>
<y>390</y>
<width>431</width>
<height>21</height>
</rect>
Expand Down Expand Up @@ -929,7 +929,7 @@ Low fps</string>
<property name="geometry">
<rect>
<x>100</x>
<y>60</y>
<y>70</y>
<width>120</width>
<height>55</height>
</rect>
Expand All @@ -943,7 +943,7 @@ Low fps</string>
<property name="geometry">
<rect>
<x>230</x>
<y>60</y>
<y>70</y>
<width>120</width>
<height>55</height>
</rect>
Expand All @@ -961,7 +961,7 @@ Object tracking
<property name="geometry">
<rect>
<x>100</x>
<y>140</y>
<y>150</y>
<width>381</width>
<height>22</height>
</rect>
Expand Down Expand Up @@ -1149,7 +1149,7 @@ Object tracking
<property name="geometry">
<rect>
<x>100</x>
<y>170</y>
<y>180</y>
<width>381</width>
<height>141</height>
</rect>
Expand Down Expand Up @@ -1320,7 +1320,7 @@ Object tracking
<property name="geometry">
<rect>
<x>360</x>
<y>60</y>
<y>70</y>
<width>120</width>
<height>55</height>
</rect>
Expand Down Expand Up @@ -1405,7 +1405,7 @@ Object Tracking
<property name="geometry">
<rect>
<x>340</x>
<y>350</y>
<y>360</y>
<width>141</width>
<height>17</height>
</rect>
Expand All @@ -1421,7 +1421,7 @@ Object Tracking
<property name="geometry">
<rect>
<x>100</x>
<y>400</y>
<y>410</y>
<width>431</width>
<height>181</height>
</rect>
Expand Down Expand Up @@ -1465,7 +1465,7 @@ Object Tracking
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<pointsize>6</pointsize>
</font>
</property>
</column>
Expand All @@ -1475,7 +1475,7 @@ Object Tracking
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<pointsize>6</pointsize>
</font>
</property>
</column>
Expand All @@ -1485,7 +1485,7 @@ Object Tracking
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<pointsize>6</pointsize>
</font>
</property>
</column>
Expand All @@ -1505,7 +1505,7 @@ Object Tracking
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<pointsize>6</pointsize>
</font>
</property>
</column>
Expand All @@ -1514,7 +1514,7 @@ Object Tracking
<property name="geometry">
<rect>
<x>100</x>
<y>380</y>
<y>390</y>
<width>101</width>
<height>21</height>
</rect>
Expand All @@ -1533,7 +1533,7 @@ Object Tracking
<property name="geometry">
<rect>
<x>380</x>
<y>380</y>
<y>390</y>
<width>151</width>
<height>23</height>
</rect>
Expand Down Expand Up @@ -1572,7 +1572,7 @@ Time, x,y, z (Skeletal Tracker)</string>
<property name="geometry">
<rect>
<x>620</x>
<y>60</y>
<y>70</y>
<width>151</width>
<height>55</height>
</rect>
Expand All @@ -1595,7 +1595,7 @@ and graph</string>
<property name="geometry">
<rect>
<x>490</x>
<y>60</y>
<y>70</y>
<width>120</width>
<height>55</height>
</rect>
Expand Down Expand Up @@ -1623,7 +1623,7 @@ and graph</string>
<property name="geometry">
<rect>
<x>100</x>
<y>40</y>
<y>50</y>
<width>641</width>
<height>21</height>
</rect>
Expand Down Expand Up @@ -1651,7 +1651,7 @@ and graph</string>
<property name="geometry">
<rect>
<x>100</x>
<y>310</y>
<y>320</y>
<width>571</width>
<height>41</height>
</rect>
Expand Down Expand Up @@ -1683,7 +1683,7 @@ Don't forget to enter the mass if you want momentum graphs.</string>
<property name="geometry">
<rect>
<x>100</x>
<y>120</y>
<y>130</y>
<width>571</width>
<height>21</height>
</rect>
Expand Down Expand Up @@ -1818,7 +1818,7 @@ then see it in 3D or find trendlines</string>
<property name="geometry">
<rect>
<x>100</x>
<y>400</y>
<y>410</y>
<width>431</width>
<height>181</height>
</rect>
Expand Down Expand Up @@ -1955,11 +1955,11 @@ Will record for a few seconds and stop</string>
<enum>Qt::PlainText</enum>
</property>
</widget>
<widget class="QComboBox" name="comboBox">
<widget class="QComboBox" name="Select3DCamera">
<property name="geometry">
<rect>
<x>100</x>
<y>28</y>
<y>30</y>
<width>171</width>
<height>18</height>
</rect>
Expand Down
13 changes: 4 additions & 9 deletions src/tracker/lib/GUI_real_time_color_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(self, color, callback):
print('color in pipe', color)

#self.current_colormap = self.HSV_COLORMAP[color]
self.lower,self.upper, self.color, self.radius_meters, self.mass = color_ranges[0]
self.lower,self.upper, self.color, self.radius_meters, self.mass = color_ranges[0]
self.color = color
self.color_ranges = color_ranges
#self.current_colormap = self.HSV_COLORMAP[color]
Expand Down Expand Up @@ -181,7 +181,7 @@ def run(self):
if not frame_result:
continue

(cv_color, rs_color, rs_depth), timestamp = frame_result
(cv_color, npy_depth, _, _), timestamp= frame_result

# Start the timer
if first_time_check:
Expand All @@ -198,10 +198,6 @@ def run(self):
i +=1
continue

# Create a colormap from the depth data TODO add if desired
#depth_image = np.asanyarray(rs_depth.get_data())
#depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.10), cv2.COLORMAP_HSV)

#from https://github.com/IntelRealSense/librealsense/issues/2204#issuecomment-414497056

hsv = make_color_hsv(cv_color)
Expand All @@ -213,7 +209,7 @@ def run(self):
if x_pixel == -1:
continue
# get.distance is a little slower so only use if necessarycenter = round(aligned_depth_frame.get_distance(int(x),int(y)),4)
x_coord, y_coord, z_coord = get_depth_meters(x_pixel, y_pixel, self.radius_meters, rs_depth, rs_color, self.zeroed_x, self.zeroed_y, self.zeroed_z, self.z)
x_coord, y_coord, z_coord = get_depth_meters(x_pixel, y_pixel, self.radius_meters, frame_result, self.zeroed_x, self.zeroed_y, self.zeroed_z, self.z)
if x_coord == -1:
continue

Expand All @@ -223,8 +219,7 @@ def run(self):

# Create a colormap from the depth data
if image.show_depth or image.save_depth:
depth_image = np.asanyarray(rs_depth.get_data())
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.10), cv2.COLORMAP_HSV)
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(npy_depth, alpha=0.10), cv2.COLORMAP_HSV)
cv2.putText(depth_colormap, 'Time: ' + str(relative_timestamp), (0,20), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50,170,50), 2)
cv2.circle(depth_colormap, (int(x_pixel), int(y_pixel)), int(radius), (255, 255, 255), 2)
# Show depth colormap & color feed
Expand Down
25 changes: 11 additions & 14 deletions src/tracker/lib/GUI_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def find_lower_upper_bounds_on_screen(the_array):
# selecting your own color boundaries by tweeking the default
pipeline = find_and_config_device()
warm_up_camera(pipeline)
(cv_color, rs_color, rs_depth), timestamp = get_all_frames_color(pipeline)
(cv_color, npy_depth, _, _ ), timestamp = get_all_frames_color(pipeline)

output = GUI_find_hsv_bounds(the_array, cv_color)
return output
Expand Down Expand Up @@ -59,7 +59,6 @@ def what_to_do_with_images(i, x_pixel, y_pixel, radius,image,depth_colormap,cv_c
else:
print("Error: Image not loaded correctly")




def GUI_tracking(pipeline, image, color_ranges, min_radius_object, data_output_folder_path, tracking_info):
Expand Down Expand Up @@ -91,8 +90,9 @@ def GUI_tracking(pipeline, image, color_ranges, min_radius_object, data_output_f
# Get frames if valid
frame_result = get_all_frames_color(pipeline)
if not frame_result:
continue
(cv_color, rs_color, rs_depth), timestamp = frame_result
continue

(cv_color, npy_depth, _, _), timestamp = frame_result

# Start the timer
if first_time_check:
Expand All @@ -105,8 +105,8 @@ def GUI_tracking(pipeline, image, color_ranges, min_radius_object, data_output_f

## Color Tracking by making a mask for each color tracked
hsv = make_color_hsv(cv_color)
depth_image = np.asanyarray(rs_depth.get_data())
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.10), cv2.COLORMAP_HSV)# Create a colormap from the depth data
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(npy_depth, alpha=0.10), cv2.COLORMAP_HSV)# Create a colormap from the depth data


for (lower,upper, color_name, radius_meters, mass) in color_ranges:
# Find location of the object in x,y pixels using color masks
Expand All @@ -128,7 +128,7 @@ def GUI_tracking(pipeline, image, color_ranges, min_radius_object, data_output_f
continue
# get.distance is a little slower so only use if necessarycenter = round(aligned_depth_frame.get_distance(int(x),int(y)),4)

x_coord, y_coord, z_coord = get_depth_meters(x_pixel, y_pixel, radius_meters, rs_depth, rs_color, zeroed_x, zeroed_y, zeroed_z, clipping_distance)
x_coord, y_coord, z_coord = get_depth_meters(x_pixel, y_pixel, radius_meters, frame_result, zeroed_x, zeroed_y, zeroed_z, clipping_distance)
if x_coord == -1 or y_coord == -1:
continue
# Append to the file until there is an error at which it will close
Expand Down Expand Up @@ -231,7 +231,7 @@ def GUI_obj_tracking(pipeline, image, color_ranges, min_radius_object, data_outp
frame_result = get_all_frames_infrared(pipeline)
if not frame_result:
continue
(rs_depth, rs_infrared), timestamp = frame_result
(npy_infrared, npy_depth, _, _), timestamp = frame_result

# Start the timer
if first_time_check:
Expand All @@ -242,12 +242,9 @@ def GUI_obj_tracking(pipeline, image, color_ranges, min_radius_object, data_outp
# Converts time from milliseconds to seconds
relative_timestamp = round(((timestamp - start_time) / 1000),3)

## TODO use rs_infrared to see infrared from camera 1
depth_image = np.asanyarray(rs_depth.get_data())
infrared_image = np.array(rs_infrared.get_data())
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.10), cv2.COLORMAP_HSV)# Create a colormap from the depth data
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(npy_depth, alpha=0.10), cv2.COLORMAP_HSV)# Create a colormap from the depth data
# image the user sees as if it were color
cv_color = infrared_image
cv_color = npy_infrared
## Color Tracking by making a mask for each color tracked

for (lower,upper, color_name, radius_meters, mass) in color_ranges:
Expand All @@ -260,7 +257,7 @@ def GUI_obj_tracking(pipeline, image, color_ranges, min_radius_object, data_outp
continue
# get.distance is a little slower so only use if necessarycenter = round(aligned_depth_frame.get_distance(int(x),int(y)),4)

x_coord, y_coord, z_coord = get_depth_meters(x_pixel, y_pixel, radius_meters, rs_depth, rs_infrared, zeroed_x, zeroed_y, zeroed_z, clipping_distance)
x_coord, y_coord, z_coord = get_depth_meters(x_pixel, y_pixel, radius_meters, frame_result, zeroed_x, zeroed_y, zeroed_z, clipping_distance)
if x_coord == -1:
continue
# Append to the file until there is an error at which it will close
Expand Down
Loading