Commit 57a4fbf5 authored by huangzhi's avatar huangzhi

add

parent 85c69ee6
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.5.4 (~/anaconda2/envs/env-35/bin/python3.5)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.5.4 (~/anaconda2/envs/env-35/bin/python3.5)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/hatdet.iml" filepath="$PROJECT_DIR$/.idea/hatdet.iml" />
</modules>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
......@@ -86,4 +86,5 @@ class DarknetYolo:
k=k+1
return lists
else:
print("Cann't detect objects,please check image!")
#print("Cann't detect objects,please check image!")
return []
......@@ -2,6 +2,9 @@ import cv2 as cv
import os.path
import darknet as interface
import argparse
import sys
import time
import datetime
configPath='hat-obj-test.cfg'
......@@ -54,22 +57,31 @@ while cv.waitKey(1) < 0:
cap.release()
break
detections_lists = []
t1 = time.time()
detections_lists = yolo.getdetresults(frame)
print(len(detections_lists ))
for i in range( len(detections_lists) ):
# get x,y,w,h
x1 = detections_lists[i][0]
y1 = detections_lists[i][1]
x2 = detections_lists[i][2]
y2 = detections_lists[i][3]
label = detections_lists[i][4]
confidence = detections_lists[i][5]
color = detections_lists[i][6]
t = time.time()
print(int(round((t-t1) * 1000)))
if detections_lists:
print(len(detections_lists ))
for i in range( len(detections_lists) ):
# get x,y,w,h
x1 = detections_lists[i][0]
y1 = detections_lists[i][1]
x2 = detections_lists[i][2]
y2 = detections_lists[i][3]
label = detections_lists[i][4]
confidence = detections_lists[i][5]
color = detections_lists[i][6]
cv.rectangle(frame, (x1, y1), (x2, y2), color, 1, lineType=cv.LINE_AA)
text = "{}: {:.4f}".format(label, confidence )
cv.putText(frame, text, (x1, y1 - 5), cv.FONT_HERSHEY_SIMPLEX,
0.5, color, 1, lineType=cv.LINE_AA)
else:
print(0)
cv.rectangle(frame, (x1, y1), (x2, y2), color, 1, lineType=cv.LINE_AA)
text = "{}: {:.4f}".format(label, confidence )
cv.putText(frame, text, (x1, y1 - 5), cv.FONT_HERSHEY_SIMPLEX,
0.5, color, 1, lineType=cv.LINE_AA)
cv.imshow("Tag", frame)
cv.imshow("Tag", frame)
#print(detections_lists)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment