From 9bb839aa6456f3600418dc090a7855fce1c320cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Fri, 22 Jun 2018 16:12:26 +0300 Subject: [PATCH] Movement developed algoirth completred --- .../.idea/codeStyles/codeStyleConfig.xml | 5 + Barcode_Reader_Python/.idea/workspace.xml | 199 ++++++++++++++---- Barcode_Reader_Python/generate_moves.py | 24 ++- Barcode_Reader_Python/generate_moves.pyc | Bin 3564 -> 3852 bytes Barcode_Reader_Python/main.py | 30 ++- Barcode_Reader_Python/move.py | 1 + 6 files changed, 205 insertions(+), 54 deletions(-) create mode 100644 Barcode_Reader_Python/.idea/codeStyles/codeStyleConfig.xml create mode 100644 Barcode_Reader_Python/move.py diff --git a/Barcode_Reader_Python/.idea/codeStyles/codeStyleConfig.xml b/Barcode_Reader_Python/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/Barcode_Reader_Python/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/Barcode_Reader_Python/.idea/workspace.xml b/Barcode_Reader_Python/.idea/workspace.xml index 3b3af7c..e0aab74 100644 --- a/Barcode_Reader_Python/.idea/workspace.xml +++ b/Barcode_Reader_Python/.idea/workspace.xml @@ -2,9 +2,11 @@ + + + - + - + - + + - + - - + + - + + + + + + - - + + @@ -47,8 +56,17 @@ - - + + + + + + + + + + + @@ -82,6 +100,7 @@ @@ -96,10 +115,10 @@ - @@ -127,7 +146,7 @@ - + - + @@ -274,15 +335,15 @@ - + - + - + @@ -292,27 +353,27 @@ + - - - - + + + + + - - - - + - - - - + + + + + @@ -321,7 +382,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -329,26 +429,43 @@ - + - - + + - + + + + + + + + - - + + + + + + + + + + + + - - + + - + diff --git a/Barcode_Reader_Python/generate_moves.py b/Barcode_Reader_Python/generate_moves.py index 6e05a81..bd6a80d 100644 --- a/Barcode_Reader_Python/generate_moves.py +++ b/Barcode_Reader_Python/generate_moves.py @@ -7,7 +7,7 @@ moved_item_loc = None exp_date = [] shelf_new = [] repeats = 0 - +moves_return = None def backArray(myArray): global shelf_back shelf_back = [] @@ -27,6 +27,7 @@ def place(): global shelf_new global repeats global shelf_back + global moves_return repeats += 1 backArray(exp_date) moved_item = None @@ -52,13 +53,16 @@ def place(): print " Moved item {0} to location {1}. Location {2} is now empty!".format(moved_item, empty_loc + 1, moved_item_loc + 1) - print "============================================================================" + print "=============================================================================" + moves_return.append(str(moved_item_loc + 1)) + moves_return.append(str(empty_loc + 1)) else: print " Leaving item {0} in location {1}. Location {2} is still empty!".format(moved_item, moved_item_loc + 1, empty_loc + 1) print "============================================================================" correct_locs.append(moved_item_loc) + place() else: return @@ -68,6 +72,9 @@ def generate(dates,date_cur): global exp_date global shelf_new global repeats + global moves_return + shelf_new = [] + moves_return = [] exp_date = sort_date. calcDate(dates,date_cur) shelf_back = exp_date[:] try: @@ -103,8 +110,8 @@ def generate(dates,date_cur): print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' print "============================================================================" exp_date[i] = None - - + moves_return.append(str(i + 1)) + moves_return.append(str(len(exp_date))) else: break place() @@ -113,6 +120,13 @@ def generate(dates,date_cur): print('***********************************************************************************') print(' The last {} items have expired, throwing them away.'.format(len(exp_date)-shelf_new.index(-1)-1)) print('***********************************************************************************') + for i in range(len(shelf_new)-1,len(shelf_new)-shelf_new.index(-1),-1): + print "aaa" + moves_return.append(str(i)) + moves_return.append("0") + except ValueError: print(" No items have expired") - print('***********************************************************************************') \ No newline at end of file + print('***********************************************************************************') + + return moves_return \ No newline at end of file diff --git a/Barcode_Reader_Python/generate_moves.pyc b/Barcode_Reader_Python/generate_moves.pyc index bc54bc8e3d00475d3d6e7a1f0082956acb4825b9..bdb4a22eb6304b88ce925fd3bd24355b3d02bb33 100644 GIT binary patch delta 1234 zcmZ8g&1(};5TAMbk!&{GG>!d;k*cji(0&MlhuVYKLTjbfriX~O*w8J~l%`GcloS#o zqz6F{>O(wO!GFMm2zn9^-u2v@cReZU#e*|%lNjCIH*aQkK7KRv-q+NF!Ibgci;NzO z+*pI=BWS-stL#5YO^hSt9Pka;1GpXm-_(o?zNMKc__k&|@DY~Mp;u1_1>RS0#CdF} zZ{j&#Ru7G-y6l2{6l4sl$cFt51p4r=T6C%lV;n#4K^0mK)uw>~GqaR(W>$tdB8Ag& zx}gDp1rvOLC0^+eRj{yuL^lA`33CqT)wX#>y))<3mboa>aphRmfhZYlZQofh-z=@m z+ogguxN=!id)9s|L41^D7f*H645*v}X+zauaeCzl)J&k#^C3;c;McVw*Ib;2 ztaMmU5~Zpf@AOQtrv%8;%z_>jYmm(r`oNSfY(}8;5)jcB)XDql+ljdeD^U5d0ONw7iKf~UeI|IK-HeY@>#?FqcOm}zUiiI8 z=(C;6lr#c6Qd~TC5hM^K5pY-vPfSq;3KS4Fis?^# z1x1_sy}Cj7^szdm3%X~l=-*i(Qfgbt!Emkc-nQ5i0(C+cQB8#{ zg;1f;Q`mhbTHOHSW-vViojHUix`vpmn^Wkq!4Xy@?O~kYZeE8UCeY_oHn)=KTsoUM zCYkb3CMbSrvkBjCjQP(3cgb(=d5nNicm5gC!yTciAhGWqtMC`SL&LW z*LIfqnrf)bI!GY D6}Y5I diff --git a/Barcode_Reader_Python/main.py b/Barcode_Reader_Python/main.py index f01d2a2..5f91c4b 100755 --- a/Barcode_Reader_Python/main.py +++ b/Barcode_Reader_Python/main.py @@ -1,4 +1,3 @@ -# import the necessary packages from imutils.video import VideoStream from pyzbar import pyzbar import imutils @@ -7,9 +6,26 @@ import cv2 import database_actions import datetime import generate_moves +import serial + +arduino = serial.Serial('/dev/ttyACM0', 115200, timeout=.1) + +def move(locations): + reps = 0 + for i in range(0,len(locations),2): + arduino.write(locations[i]) + while(arduino.read() == '\x00'): + continue + + arduino.write(locations[i+1]) + while(arduino.read() == '\x00'): + continue + + + -# initialize the video stream and allow the camera sensor to warm up print("[INFO] starting video stream...") + def dateStr(): date_cur = "" if len(str(datetime.date.today().day)) == 1: @@ -22,7 +38,6 @@ def dateStr(): date_cur = date_cur + str(datetime.date.today().month) + "." date_cur += str(datetime.date.today().year) return date_cur -# vs = VideoStream(src=0).start() vs = VideoStream().start() time.sleep(2.0) dates = [] @@ -32,10 +47,8 @@ prevcode = None exp_date = [] current_date = dateStr() -print current_date -# loop over the frames from the video stream while reps<1: - # grab the frame from the threaded video stream and resize it to + try: while (barcodes == None or barcodes == []): frame = vs.read() @@ -61,6 +74,7 @@ while reps<1: print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData)) dates.append(database_actions.getDate(barcodeData)) reps += 1 + arduino.write("1") prevcode = barcodeData barcodes = None @@ -69,10 +83,10 @@ while reps<1: break except KeyboardInterrupt: break -# close the output CSV file do a bit of cleanup + print("[INFO] cleaning up...") print dates -generate_moves.generate(dates,current_date) +print generate_moves.generate(dates,current_date) cv2.destroyAllWindows() vs.stop() \ No newline at end of file diff --git a/Barcode_Reader_Python/move.py b/Barcode_Reader_Python/move.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Barcode_Reader_Python/move.py @@ -0,0 +1 @@ +