top of page

Week #21 - 06/18 - 06/25

  • Nicolo Agostini
  • Jun 24, 2024
  • 3 min read

Updated: Jun 25, 2024

Group:


The touchscreen was delivered during the previous week, so installation of the final components took place during the weekend. The touchscreen was mounted and wired to the Raspberry Pi, fully completing the construction of the project.

Additionally, a dog was brought in to test the functionality of the OpenCV programming and to see what the initial reaction to the door would be. During testing it was noted that the dog detection was inconsistent and that other methods might be needed to implement the recognition software. Also, the dog was not receptive to the door at all, to the point of being scared of the door. Plans to test the door with a different dog are being made, and testing will be continued in the next week.


We worked together to attempt to develop our own cascade file using a xml file generator GUI that was found online. These attempts were unsuccessful. It was decided that a different methodology of opening the door would need to be implemented.




Nick:

In order to test the cascade files accurately I wrote a short python program that uses the computer's webcam to capture an image and search for an object using OpenCV. The program draws a box around the detected object.


cascade_path = 'dog3.xml'

cascade_file = cv2.CascadeClassifier(cascade_path)


def dog_detection(img):

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

dog_face = cascade_file.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(50, 50))


for (x, y, w, h) in dog_face:

cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 5)

return img, len(dog_face)



cam1 = cv2.VideoCapture(0) # Camera 1


while cam1.isOpened():

ret1, frame1 = cam1.read()

frame1_with_dogs, num_dogs1 = dog_detection(frame1)

cv2.imshow('Dog Detection Test - Camera 1', frame1_with_dogs)

key = cv2.waitKey(1) & 0xFF

if key == ord('q'):

break

cam1.release()

cv2.destroyAllWindows()




After testing our current cascade files and many others found online, I concluded that none of them would be accurate enough for our purpose and that we needed to create our own cascade file.


At the same time, I have been researching alternative methods for detecting objects using OpenCV and found this guide:



In this guide they explain step by step how to use OpenCV combined with the Common Objects in Context (COCO) library.


Following their sample code, I was able to write a program that would very accurately detect a dog.







After testing and coordinating with Ryan, we agreed to replace the previous image detection method with this new approach. This code was sent to Ryan for implementation into the doggy door's main code.


"New Approach" Pros:


  • No cascade file needed

  • The detection uses a pre-train model

  • Ability to easily adjust the confidence level of the detection.

  • Excellent reliability in detecting a dog


"New Approach" Cons:

  • As a pre-trained model is used, the doggy door will only be able to detect a generic dog



Ryan:


The revised plan was sent to me by Nick for me to implement the code into the main program. I first tested the code on my laptop and found that the recognition software was working as expected. I downloaded the code to the Raspberry Pi, and ran into issues executing the code. More time to troubleshoot the implementation to the Pi will be needed.


Additionally, I wrote a few lines of code that would be used to replace the cascade file method to run the opening script for the door with the COCO object recognition library instead:


def scan(): 

    ret1, frame1 = cam1.read() 

    ret2, frame2 = cam2.read() 

    frame1_with_objects, objectInfo1 = getObjects(frame1, 0.55, 0.2, objects=["dog"]) 

    frame2_with_objects, objectInfo2 = getObjects(frame2, 0.55, 0.2, objects=["dog"]) 

  

    if objectInfo1 or objectInfo2: 

        if is_within_time_window(datetime.datetime.now().time()): 

            opensequence()


Executing the newly written code on the Pi was not successful due to the Pi not being able to recognize an image of the dog. I added a camera feed to the code for troubleshooting purposes and still had no luck. This code will need to be troubleshot further in order to fully implement it into the project. A fully functioning version of the code will be completed before testing with the new dog later this week.

1596494170937.jfif

Nicolo is a 26-years-old student at Valencia College, pursuing a B.S. in Electrical and Computer Engineering Technology. Nicolo is currently an intern at a MEP engineering firm in Orlando, FL, working on a variety of projects including the local theme parks and rocket launch sites. When not in class, Nicolo enjoys working on DIY electrical projects, outdoors activities, and visiting the theme parks. 

image.png

Ryan is a 28-year-old Electrical and Computer Engineering Technology student at Valencia College. When not in class, he enjoys working on DIY projects, repairing cars, and cooking. Ryan recently began a Systems Engineering Internship at Walt Disney Imagineering for the Spring 2024 semester. After graduation, he hopes to continue his engineering career at Walt Disney Imagineering.

bottom of page