add sorting code, saving to file
This commit is contained in:
parent
e21628b608
commit
bcfd61a7cf
BIN
__pycache__/sort.cpython-38.pyc
Normal file
BIN
__pycache__/sort.cpython-38.pyc
Normal file
Binary file not shown.
BIN
bins_default.txt
Normal file
BIN
bins_default.txt
Normal file
Binary file not shown.
Binary file not shown.
BIN
detect.cpython-38-x86_64-linux-gnu.so
Executable file
BIN
detect.cpython-38-x86_64-linux-gnu.so
Executable file
Binary file not shown.
@ -1,4 +1,5 @@
|
||||
import detect
|
||||
import sort
|
||||
import timeit
|
||||
import cv2
|
||||
from imutils.video import FPS
|
||||
@ -22,6 +23,7 @@ def go():
|
||||
break
|
||||
if valid:
|
||||
print("Found " + itema)
|
||||
bin = sort.sort(itema)
|
||||
|
||||
if not video:
|
||||
elapsed_time = timeit.timeit(go, number=1)/1
|
||||
|
31
sort.py
Normal file
31
sort.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Sort items
|
||||
import pickle
|
||||
|
||||
def write(bins):
|
||||
file = open("bins.txt","w+b")
|
||||
pickle.dump(bins, file)
|
||||
file.close()
|
||||
|
||||
def sort(input):
|
||||
file = open("bins.txt","a+b")
|
||||
file.close()
|
||||
file = open("bins.txt", "rb")
|
||||
bins = pickle.load(file)
|
||||
|
||||
|
||||
if len(bins) == 0:
|
||||
bins = ['Unknown']
|
||||
file.close()
|
||||
write(bins)
|
||||
#file.write(str(bins))
|
||||
if bins.count(input) == 0:
|
||||
bins.append(input)
|
||||
bin = bins.index(input)
|
||||
print(str(bins))
|
||||
print(bin)
|
||||
write(bins)
|
||||
return bin
|
||||
|
||||
def clear():
|
||||
write(["Unknown"])
|
||||
write(["Unknown"])
|
Loading…
x
Reference in New Issue
Block a user