From 5c924a923c3755de8d40eb527eefa42710338a53 Mon Sep 17 00:00:00 2001 From: brennandmcdonald <71531277+brennandmcdonald@users.noreply.github.com> Date: Sat, 17 Oct 2020 17:05:34 -0400 Subject: [PATCH 1/4] detect.py --- .idea/workspace.xml | 318 ++++++++++++++--------------------- Arjun:Josh Sliding window.py | 34 ++-- detect.py | 35 ++++ 3 files changed, 179 insertions(+), 208 deletions(-) create mode 100644 detect.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b1509c0..2ee4600 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,76 +1,40 @@ + + + + + + + + + + + + + + + + + - - - - + + + @@ -135,19 +68,33 @@ - - + + + + - + + + + + + + + + + @@ -220,36 +191,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -258,65 +244,7 @@ 9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Arjun:Josh Sliding window.py b/Arjun:Josh Sliding window.py index 9e92711..0da3927 100644 --- a/Arjun:Josh Sliding window.py +++ b/Arjun:Josh Sliding window.py @@ -1,30 +1,38 @@ import apriltag import cv2 +import os import numpy as np -#gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) +# gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) - # slide a window across the image -def reader(img): - tagList = [] +# slide a window across the image +def reader(detector, img, file_name): + tag_list = [] global img2 for y in range(0, img.shape[0], 350): for x in range(0, img.shape[1], 350): - - result, img2 = detector.detect(img[y:y + 450, x:x + 450], return_image = True) - if ((len(result) != 0) and result not in tagList): - tagList.append(result) - print(result) - cv2.imwrite("output.jpg",img2) + result, img2 = detector.detect(img[y:y + 450, x:x + 450], return_image=True) + if (len(result) != 0) and any(result) not in tag_list: + tag_list.append(result) + print(result) + cv2.imwrite("Outputs/"+file_name+".output.jpg", img2) +def compareTag(apriltag, tagList): + for tag in tagList: + if apriltag["tag_family"] == tag["tag_family"] and apriltag["tag_id"] == tag["tag_id"]: + return True + return False if __name__ == '__main__': cap = cv2.VideoCapture(0) - detector = apriltag.Detector() - img = cv2.imread("data/Track 10-22/90_0.png", cv2.IMREAD_GRAYSCALE) - reader(img) + det = apriltag.Detector() + directory = "data/Track 10-22/" + for file in os.listdir(directory): + print(file) + img = cv2.imread(directory+file, cv2.IMREAD_GRAYSCALE) + reader(det, img, file) cap.release() cv2.destroyAllWindows() diff --git a/detect.py b/detect.py new file mode 100644 index 0000000..d25af35 --- /dev/null +++ b/detect.py @@ -0,0 +1,35 @@ +import apriltag +import cv2 +import os +import numpy as np + + +# gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + + +# slide a window across the image +def reader(detector, img, file_name): + tag_list = [] + global img2 + + for y in range(0, img.shape[0], 350): + for x in range(0, img.shape[1], 350): + result, img2 = detector.detect(img[y:y + 450, x:x + 450], return_image=True) + print(result) + if (len(result) != 0) and all(result) not in tag_list: + tag_list.append(result) + cv2.imwrite("Outputs/"+file_name+".output.jpg", img2) + return tag_list + + +if __name__ == '__main__': + cap = cv2.VideoCapture(0) + detector = apriltag.Detector() + directory = "data/Track 10-22/" + file = directory+"60_2.png" + print(file) + img = cv2.imread(file, cv2.IMREAD_GRAYSCALE) + tag_list = reader(detector, img, file) + print(tag_list) + cap.release() + cv2.destroyAllWindows() From 3a9be72580198a13d6f143be91bebb292968b612 Mon Sep 17 00:00:00 2001 From: brennandmcdonald <71531277+brennandmcdonald@users.noreply.github.com> Date: Sat, 24 Oct 2020 16:59:21 -0400 Subject: [PATCH 2/4] detect.py --- .idea/workspace.xml | 116 +++++++++++++++++++++++++++++++++++++------- detect.py | 2 +- output.png | Bin 0 -> 644559 bytes test.py | 16 ++++++ 4 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 output.png create mode 100644 test.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee4600..d22c987 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -19,10 +19,11 @@