Skip to content

Commit

Permalink
feat: integrate with streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziad-Muhammed committed Sep 21, 2022
1 parent bd615b6 commit 2a0d2b3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 44 deletions.
78 changes: 43 additions & 35 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import glob
import imp
import os

Expand All @@ -20,7 +21,7 @@
import sys

path = './outputs/'
url = "http://192.168.1.103:8080/video"
url = "http://192.168.98.146:8080/video"
sys.path.insert(0, './localisation')
import detect as detect
# from segmentation.seg import Segmentation
Expand All @@ -46,40 +47,47 @@ def printChars(chars, count):

# Main which responsible for integration of whole image processing pipelines
if __name__ == '__main__':
try:
countPlate = 1
# stream(url)

# localization
detect.crop_multiple("./localisation/data/demo")[0]

for filename in os.scandir("./detections/"):
try:
# segmentation
_, chars = segmentChars(filename.path)

# print chars segmented
printChars(chars, countPlate)

# recognition
predicted_chars = classify_unlabelled_directory(f'{path}{countPlate}/')

# print string
lp = predictChars(predicted_chars)
print(lp)

os.rmdir(f'./outputs/{countPlate}')
countPlate += 1

# send string to middle-ware
endPoint(lp)

except Exception:
# print("error")
continue

except SystemExit:
pass
while True:
try:
countPlate = 1
# stream(url)

# localization
detect.crop_multiple("./localisation/data/demo/")[0]

for filename in os.scandir("./detections/"):
try:
# segmentation
_, chars = segmentChars(filename.path)

# print chars segmented
printChars(chars, countPlate)

# recognition
predicted_chars = classify_unlabelled_directory(f'{path}{countPlate}/')

# print string
lp = predictChars(predicted_chars)
print(lp)

# countPlate += 1

# send string to middle-ware
# endPoint(lp)
# files = glob.glob('./detections/*')
# for file in files:
# os.remove(file)
# files = glob.glob('./outputs/*')
# for file in files:
# os.remove(file)

except Exception:
# print("error")
continue

except Exception:
print("outer error")
continue

# segObject = Segmentation(filename.path)
# chars = segObject.run()
Expand Down
24 changes: 15 additions & 9 deletions testing/webcam.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import glob

import cv2 as cv
import os

path = '../outputs/'
path = './localisation/data/images/1.png'


def stream():
link = "http://192.168.1.103:8080/video"
def stream(link):
# link of streaming
# link = "http://9.246.91.33:8080/video"
capture = cv.VideoCapture(link)
files = glob.glob('./localisation/data/images/*')
for file in files:
os.remove(file)
while True:

_, frame = capture.read()
Expand All @@ -15,16 +21,16 @@ def stream():

# take photo from streaming
if cv.waitKey(1) == ord("q"):
cv.imwrite(f'{path}1.png', frame)
continue

# exit streaming
if cv.waitKey(1) == ord('z'):
cv.imwrite(path, frame)
break

# # exit streaming
# if cv.waitKey(1) == ord('z'):
# break

# destroy streaming
capture.release()
cv.destroyAllWindows()
#ds
# ds

# stream()

0 comments on commit 2a0d2b3

Please sign in to comment.