Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
fixed tracker issues, changed port to 5805
Browse files Browse the repository at this point in the history
  • Loading branch information
halihuang committed Feb 15, 2020
1 parent 33534b0 commit 150de54
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 157 deletions.
Binary file removed .config.py.swp
Binary file not shown.
6 changes: 3 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# when using static ip for robot
#config.networktables_server_ip = '10.26.1.11'

config.video_source_number = 1
config.long_video_source_number = 0
config.video_source_number = 0
config.wide_video_source_number = 1
config.networktables_table = 'SmartDashboard'

config.gstreamer_bitrate = '3500000'
Expand All @@ -16,4 +16,4 @@

# config.gstreamer_pipeline = 'appsrc ! videoconvert ! omxh265enc bitrate=%s ! video/x-h265, stream-format=(string)byte-stream ! h265parse ! rtph265pay ! udpsink host=%s port=%s' % (config.gstreamer_bitrate, config.gstreamer_client_ip, config.gstreamer_client_port)

tornado_server_port="8080"
tornado_server_port="5805"
14 changes: 7 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def main(): # main method defined

if(main_controller.enable_dual_camera):
longCam = USBCam()
longCam.open(config.long_video_source_number)
longCam.open(config.wide_video_source_number)

# Set camera properties
# cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
Expand Down Expand Up @@ -97,11 +97,11 @@ def main(): # main method defined

time.sleep(5)

camera_ws = create_connection("ws://localhost:8080/camera/ws")
processed_ws = create_connection("ws://localhost:8080/processed/ws")
calibration_ws = create_connection("ws://localhost:8080/calibration/ws")
tracking_ws = create_connection("ws://localhost:8080/tracking/ws")
controller_listener.start("ws://localhost:8080/dashboard/ws")
camera_ws = create_connection("ws://localhost:5805/camera/ws")
processed_ws = create_connection("ws://localhost:5805/processed/ws")
calibration_ws = create_connection("ws://localhost:5805/calibration/ws")
tracking_ws = create_connection("ws://localhost:5805/tracking/ws")
controller_listener.start("ws://localhost:5805/dashboard/ws")

logger.info('starting main loop ')
frame_cnt = 0
Expand All @@ -117,7 +117,7 @@ def main(): # main method defined
print('opening camera')
if main_controller.enable_dual_camera:
longCam.open(config.video_source_number)
mainCam.open(config.wide_cam_source_number)
mainCam.open(config.wide_video_source_number)
# if the cap is not already open, do so

if main_controller.camera_mode == CAMERA_MODE_HEXAGON and main_controller.enable_dual_camera:
Expand Down
1 change: 0 additions & 1 deletion network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

from network import color_profile_listener

from network.tracking_data_poster import send_tracking
5 changes: 0 additions & 5 deletions network/tracking_data_poster.py

This file was deleted.

Binary file removed processing/.ball_tracker2.py.swp
Binary file not shown.
131 changes: 0 additions & 131 deletions processing/ball_tracker.py

This file was deleted.

2 changes: 1 addition & 1 deletion processing/ball_tracker2.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def process(img, camera, frame_cnt, color_profile):
radius_text = 'radius:%s' % (radius)
coordinate_text = 'x:%s y:%s ' % (center_mass_x, center_mass_y)
area_text = 'area:%s width:%s height:%s' % (area, w, h)
angle_text = 'angle:%.2f distance:%s' % (angle, distance)
angle_text = 'angle:%.2f distance:%.2f' % (angle, distance)

cv2.putText(original_img, coordinate_text, (int(x), int(y) - 35), font, .4, colors.WHITE, 1, cv2.LINE_AA)
cv2.putText(original_img, area_text, (int(x), int(y) - 20), font, .4, colors.WHITE, 1, cv2.LINE_AA)
Expand Down
2 changes: 1 addition & 1 deletion processing/bay_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def process(img, camera, frame_cnt, color_profile):
vertices_text = 'vertices:%s' % (num_vertices)
coordinate_text = 'x:%s y:%s ' % (center_mass_x, center_mass_y)
area_text = 'area:%s width:%s height:%s' % (area, w, h)
angle_text = 'angle:%.2f distance:%s' % (angle, distance)
angle_text = 'angle:%.2f distance:%.2f' % (angle, distance)

cv2.putText(original_img, coordinate_text, (x, y - 35), font, .4, colors.WHITE, 1, cv2.LINE_AA)
cv2.putText(original_img, area_text, (x, y - 20), font, .4, colors.WHITE, 1, cv2.LINE_AA)
Expand Down
4 changes: 2 additions & 2 deletions processing/port_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def process(img, camera, frame_cnt, color_profile):
#
if shape_util.dimensions_match(contour, 6,2, WIDTH_TO_HEIGHT_RATIO):
# print 'x:%s, y:%s angle:%s ' % ( center_mass_x, center_mass_y, angle )
distance = shape_util.distance_in_inches(w)
distance = shape_util.distance_in_inches_long(w)
angle = shape_util.get_angle(camera, center_mass_x, center_mass_y)
font = cv2.FONT_HERSHEY_DUPLEX

Expand All @@ -89,7 +89,7 @@ def process(img, camera, frame_cnt, color_profile):
vertices_text = 'vertices:%s' % (num_vertices)
coordinate_text = 'x:%s y:%s ' % (center_mass_x, center_mass_y)
area_text = 'area:%s width:%s height:%s' % (area, w, h)
angle_text = 'angle:%.2f distance:%s' % (angle, distance)
angle_text = 'angle:%.2f distance:%.2f' % (angle, distance)

cv2.putText(original_img, coordinate_text, (x, y - 35), font, .4, colors.WHITE, 1, cv2.LINE_AA)
cv2.putText(original_img, area_text, (x, y - 20), font, .4, colors.WHITE, 1, cv2.LINE_AA)
Expand Down
3 changes: 3 additions & 0 deletions processing/shape_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ def get_distance(width_pixel, width_actual, focal_length):

def distance_in_inches(width_pixel):
return 762 * (width_pixel ** -0.8)

def distance_in_inches_long(width_pixel):
return 34618 * x ** -1.06
89 changes: 85 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,86 @@
pynetworktables==2019.0.2
apt-clone==0.2.1
apturl==0.5.2
asn1crypto==0.24.0
beautifulsoup4==4.6.0
blinker==1.4
Brlapi==0.6.6
certifi==2018.1.18
chardet==3.0.4
cryptography==2.1.4
cupshelpers==1.0
Cython==0.29.15
defer==1.0.6
distro-info===0.18ubuntu0.18.04.1
feedparser==5.2.1
gevent==1.4.0
graphsurgeon==0.4.1
greenlet==0.4.15
html5lib==0.999999999
httplib2==0.9.2
idna==2.6
Jetson.GPIO==2.0.4
keyring==10.6.0
keyrings.alt==3.0
language-selector==0.1
launchpadlib==1.10.6
lazr.restfulclient==0.13.5
lazr.uri==1.0.3
louis==3.5.0
lxml==4.2.1
macaroonbakery==1.1.3
Mako==1.0.7
MarkupSafe==1.0
numpy==1.13.3
oauth==1.0.1
oauthlib==2.0.6
PAM==0.4.2
Pillow==7.0.0
protobuf==3.0.0
pycairo==1.16.2
pycrypto==2.6.1
pycups==1.9.73
pygobject==3.26.1
PyICU==1.9.8
PyJWT==1.5.3
pymacaroons==0.13.0
PyNaCl==1.1.2
pynetworktables==2020.0.2
pyRFC3339==1.0
python-apt==1.6.4
python-dateutil==2.6.1
python-debian==0.1.32
pytz==2018.3
pyxdg==0.25
PyYAML==3.12
requests==2.18.4
requests-unixsocket==0.1.5
SecretStorage==2.3.1
simplejson==3.13.2
six==1.14.0
ssh-import-id==5.7
system-service==0.3
systemd-python==234
tensorrt==6.0.1.10
tornado==6.0.3
zmq=0.0.0
Pillow>=5.3.0
opencv-python==3.2.0
ubuntu-drivers-common==0.0.0
uff==0.6.5
ujson==1.35
unity-scope-calculator==0.1
unity-scope-chromiumbookmarks==0.1
unity-scope-colourlovers==0.1
unity-scope-devhelp==0.1
unity-scope-firefoxbookmarks==0.1
unity-scope-manpages==0.1
unity-scope-openclipart==0.1
unity-scope-texdoc==0.1
unity-scope-tomboy==0.1
unity-scope-virtualbox==0.1
unity-scope-yelp==0.1
unity-scope-zotero==0.1
urllib3==1.22
wadllib==1.3.2
webencodings==0.5
websocket==0.2.1
websocket-client==0.57.0
xkit==0.0.0
zope.interface==4.3.2
2 changes: 1 addition & 1 deletion test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main():
#TODO: if no camera, exit and msg no camera
time.sleep(5)
logger.info('starting main loop')
ws = create_connection("ws://localhost:8080/tracking/ws")
ws = create_connection("ws://localhost:5805/tracking/ws")

frame_cnt = 0
while(True):
Expand Down
Binary file removed web/.tornado_server.py.swp
Binary file not shown.
3 changes: 2 additions & 1 deletion web/www/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ function draw(targets) {
size = target.width;
octx.beginPath();
octx.moveTo(x + size * Math.cos(0), y + size * Math.sin(0));
for (var side; side < 7; side++) {
for (var side = 0; side < 7; side++) {
octx.lineTo(x + size * Math.cos(side * 2 * Math.PI / 6), y + size * Math.sin(side * 2 * Math.PI / 6));
}
octx.fill();
octx.closePath();
}
})
ctx.clearRect(0, 0, canvas.width, canvas.height);
Expand Down

0 comments on commit 150de54

Please sign in to comment.