Skip to content

Commit 077222b

Browse files
committed
new factoring
1 parent 2a07c21 commit 077222b

14 files changed

+14
-456
lines changed

.gitignore

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
checkpoints
1+
checkpoints/*
22
android
33
camera
44
result
5-
detections
5+
detections/*
66
*.weights
77
/ocr/weights_best.pb.*
88
venv
9+
detect_simple.py
10+
detect_simple2.py
11+
main.py
912
*.ipynb
1013
.idea
1114
.vscode
12-
__pycache__
15+
__pycache__

checkpoint

-2
This file was deleted.
26 Bytes
Binary file not shown.
26 Bytes
Binary file not shown.
26 Bytes
Binary file not shown.
-13 Bytes
Binary file not shown.

core/__pycache__/utils.cpython-38.pyc

-8 Bytes
Binary file not shown.
26 Bytes
Binary file not shown.

core/functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def crop_objects(img, data, path, allowed_classes):
2020
#create dictionary to hold count of objects for image name
2121
jdict = [{"location": f"A{i+1}", "inOut": "out"} for i in range(3)]
2222
counts = dict()
23-
idx = 0;
23+
idx = 0
2424
for i in range(num_objects):
2525
# get count of class for part of image name
2626
class_index = int(classes[i])
@@ -35,7 +35,7 @@ def crop_objects(img, data, path, allowed_classes):
3535
# crop detection from image (take an additional 5 pixels around all edges)
3636
cropped_img = img[int(ymin):int(ymax), int(xmin):int(xmax)]
3737
# construct image name and join it to path for saving crop properly
38-
img_name = class_name + '_' + str(counts[class_name]) + '.jpg'
38+
img_name = class_name + '_' + str(location[-1]) + '.jpg'
3939
img_path = os.path.join(path, img_name)
4040
# save image
4141
cv2.imwrite(img_path, cropped_img)

core/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def image_preprocess(image, target_size, gt_boxes=None):
135135
gt_boxes[:, [1, 3]] = gt_boxes[:, [1, 3]] * scale + dh
136136
return image_paded, gt_boxes
137137

138-
def draw_bbox(image, bboxes, disabled, show_label=True):
138+
def draw_bbox(image, bboxes, disabled=0, show_label=True):
139139
if disabled == 0:
140140
classes=read_class_names(cfg.YOLO.CLASSES)
141141
num_classes = len(classes)

detect_simple.py

-118
This file was deleted.

detect_simple2.py

-117
This file was deleted.

detectvideo.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@
1414
from tensorflow.compat.v1 import ConfigProto
1515
from tensorflow.compat.v1 import InteractiveSession
1616

17-
flags.DEFINE_string('framework', 'tf', '(tf, tflite, trt')
18-
flags.DEFINE_string('weights', './checkpoints/yolov4-416',
17+
flags.DEFINE_string('framework', 'tflite', '(tf, tflite, trt')
18+
flags.DEFINE_string('weights', './checkpoints/yolov4-416.tflite',
1919
'path to weights file')
2020
flags.DEFINE_integer('size', 416, 'resize images to')
2121
flags.DEFINE_boolean('tiny', False, 'yolo or yolo-tiny')
2222
flags.DEFINE_string('model', 'yolov4', 'yolov3 or yolov4')
23-
flags.DEFINE_string('video', 'parking.mp4', 'path to input video')
23+
flags.DEFINE_string('video', '0', 'path to input video')
2424
flags.DEFINE_float('iou', 0.45, 'iou threshold')
2525
flags.DEFINE_float('score', 0.25, 'score threshold')
2626
flags.DEFINE_string('output', None, 'path to output video')
2727
flags.DEFINE_string('output_format', 'XVID', 'codec used in VideoWriter when saving video to file')
2828
flags.DEFINE_boolean('dis_cv2_window', False, 'disable cv2 window during the process') # this is good for the .ipynb
29+
url = 'rtsp://admin:[email protected]/'
2930

3031
def main(_argv):
3132
config = ConfigProto()
@@ -36,7 +37,7 @@ def main(_argv):
3637
video_path = FLAGS.video
3738

3839
print("Video from: ", video_path )
39-
vid = cv2.VideoCapture(video_path)
40+
vid = cv2.VideoCapture(url)
4041

4142
if FLAGS.framework == 'tflite':
4243
interpreter = tf.lite.Interpreter(model_path=FLAGS.weights)

0 commit comments

Comments
 (0)