Pattern | Implemented? | Purpose | |
---|---|---|---|
1 |
Singleton |
YES |
Only 1 admin |
2 |
Factory |
YES |
Detected objects by the camera |
3 |
Prototype |
YES |
Implementation of different detection algorithms |
4 |
Object Pool |
YES |
A Pool of Available Cameras |
5 |
Builder |
YES |
Not related to project |
6 |
Abstract Factory |
YES |
GUI for QT and GTK |
7 |
Iterator |
YES |
Iterator for detected objects |
8 |
Observer |
YES |
Event logging |
9 |
Memento |
NO |
- |
10 |
Mediator* |
NO |
- |
11 |
Decorator^ |
YES |
Coffee ordering feature without leaving the station |
[*] Chain of Responsibility - Command - Visitor - Mediator
[^] Adapter - Decorator - Component
Bu projede bir güvenlik sistemi ROS kullanarak geliştirmeye çalıstım. Sistemde bir Publisher ve bir Subscriber var. Publisher kameradan görüntü alıp üzerinde nesne tespiti yapacak, görüntü ve tespit sonucu ayrı 'topic' olarak yayınlayacak. Subscriber o mesajları alıp, bir yöneticiyi gösterecek, yönetici şüpheli bir nesne görürse onu işaretleyebilir.
Proje tam olmadığı için her şey çalışmıyor (ör: GUI) ama kullandığım Örüntülerin demosu yapabilmek için yeterli kısmı bitirdim. Örüntüler ağşada anlatığım gibi kullandım:
publisher’de 4 örüntü ekledim:
from object_pool import object_pool
from prototype import prototype
from iterator import iterator
from builder import builder
Nesne tespit etmek için farkla algoritmalar var (YOLO, SSD, RCNN …), her algoritma için bir Prototype Detector var, ve kullanıcı onlardan bir ya da daha fazla seçebilir.
Resimdeki Nesneleri tespit ettikten sonra, onları kolay incelemek ve işleme için bir Iterator yazdım.
subscriber’de 5 örüntü ekledim
from singleton import singleton
from factory import factory
from abstract_factory import abstract_factory
from observer import
from decorator_ import decorator as dec
Kontrol paneli için tek bir yönetici kullanabilir, onun için Singleton örüntüyü kullandım.
Farklı sistemler için GUI yapabilmek için, bu örüntü kullanılabilir, mesala hem GNOME (GTK) hem de KDE (QT) destekleyebilmek için.
Observer 2 şekilde kullandım: 1- ROS kendi Subscriber kullanarak 2 callback fonksyonu var. 2- bazı önemli olayları kaydedebilmek için, Observer örüntü yardımıyla bir 'Event Logger' yaptım.