N.B. This application note is validated for HV7131GP camera module, not supported any more. Similar examples are being produced for the OV9650 camera module (embedded in the Seed-Eye board). You can also take inspiration and contribute by yourself!
IPERMOB Parking Slot Monitor Application Note
Andrea Azzarà (SSSA)
This application note provides a simplified version of Ipermob parking slot application and it's composed of three main software blocks:
- Sensor Device. It performs image acquisition, runs a cv algorithm and sends the results to the coordinator;
- Coordinator Device. Allows the user to communicate with the device, performing configuration tasks, and sends algorithm results to the user;
- Test Client. It's a PC application allowing the communication with the coordinator.
For the sake of simplicity this application differs from Ipermob application in some parts:
- the sensor nodes are not synchronized, the coordinator doesn't send queries at regular intervals;
- There are no real-time guarantees on the results;
- Sensors sends algorithm results to the coordinator asynchronously, each with it's own period, specified in a configuration file.
- 2 PIC32 Seed Eye Boards
- Camera Board with HV7131GP camera
- 1 Microchip programming interface (ICD3 or PICkit)
- Ethernet cable
The application has been tested on a Linux host.
The following softwares are required to compile and run this application note:
- Erika + RTDruid
- MPLAB X IDE
- MPLAB C32 Compiler
- uCV Library (not included in Erika EE)
To install and configure Erika Enterprise with RTDruid, MPLAB X IDE and MPLAB C32 Compiler please refer to:
Once installed move (or link) uCV folder to Erika Contrib Folder
To display and convert the images received from the sensors the following Python package is used: PIL Python Imaging Library
Running the Demo
Folder exe contains precompiled executables for both Pic32 boards.
Load the executables on the microcontrollers with MPLAB IDE.
Compile and run client application:
$ cd client/Debug
$ ./app_note_client -i 172.16.6.2 -t
Set timestamp ok
Listen for incoming messages from coordinator
$ ./app_note_client -i 172.16.6.2 -l
Stalli - Numero sensori monitorati: 1 , t= Tue Jul 12 15:07:29 2011
Sensore 0x0000000000000003 , n stalli 3
Slot ID 65 - 0041 , Status 12 - 0x0C
Slot ID 66 - 0042 , Status 12 - 0x0C
Slot ID 67 - 0043 , Status 12 – 0x0C
The client will report status messages coming from sensor nodes, displaying for every sensor:
- the sensor id;
- the number of slot monitored;
- the status of every slot. The status is a value expressed on 1 byte. Higher values mean higher probability for the slot to be occupied.
Coordinator can be in three different states:
In the Init state the coordinator is waiting for time-stamp synchronization message from the client. When the time stamp is received the coordinator switches to Running state. In Running state the coordinator receives update messages from WSN nodes and forwards them to the client on Ethernet interface. In Maintenance state the coordinator doesn't send any update message to the client.
To get coordinator state run:
$ ./app_note_client -i 172.16.6.2 -c
Get coordinator status
Sensore 0x0000000000000001 RUNNING
Dynamic nodes configuration
Nodes can be configured when the coordinator is in Maintenance state.
To enter Maintenance state use the following command:
$ ./app_note_client -i 172.16.6.2 -s
To exit Maintenance state and go back in Running state use the following command:
$ ./app_note_client -i 172.16.6.2 -e
The system allows the transfer and visualization of the last image captured by the camera or the background image.
To receive the last image use the following command:
$ ./app_note_client -i 172.16.6.2 -m -a 3
To receive the background image use the following command:
$ ./app_note_client -i 172.16.6.2 -b -a 3
Images are shown on the screen and saved in folder client/images.
The command to configure the ROI in a sensor is:
$ ./app_note_client -i 172.16.6.2 -g ../roi_cfg.roi -a 3
roi_cfg.roi is a text file containing the informations needed to configure the ROI on a sensor, i.e., number of ROI, IDs for every ROI (parking slot), coordinates and initial state.
The number of the ROI matches the number of lines in the file.
Coordinates are expressed in pixels starting from the origin (top left corner of the image). Every ROI is identified by 4 points (Top Left, Top Right, Bottom Left, Bottom Right).
Init state can be one of the following:
- background invalid (Background empty or wrong) - code 0;
- background valid (Background good and valid) - code 1;
- replace background (Background must be updated now. This value is transient) - code 2.
Client folder contains an example of ROI configuration file, roi_cfg.roi .
ROI configuration is saved in flash on the device.
Building the project
Create two RTDruid empty projects in Eclipse (Coordinator and Device) and copy the content of coordinator and device folders in the corresponding workspace directories. Copy common directory in the workspace. Build the projects.
Static node configuration
Coordinator node can be configured modifying coordinator/conf.h file. The main parameters are:
- 802.15.4 parameters: channel, node ID, network ID (PAN ID), Beacon Order, Superframe Order;
- Microchip TCP/IP stack parameters: IP address, Network mask, UDP port.
Sensing node can be configured modifying /device/firmware_conf.h file. The main parameters are:
- Sensor ID (SID);
- Image Size;
- 802.15.4 parameters: channel, device ID, coordinator ID, network ID. Must match with the ones specified for the coordinator.
- Signaling Period, PERIODIC_QUERY_PERIOD, in ms.
Supported image size are 160x120 and 320x240 pixel.
Default ROI configuration can be modified editing ROI initialization in function use_default_rois(), in algorithm_func_slot.c file in device/stalli/ directory.
Multiple devices can be connected to the same coordinator. To do that just change Sensor ID in the configuration file and build again the device.
- Daniele Alessandrelli
- Andrea Azzarà
- Bernardo Dal Seno
- Massimo Magrini
- Davide Moroni
- Gabriele Pieri
- Ovidio Salvetti