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)

Download File

Introduction


This application note provides a simplified version of Ipermob parking slot application and it's composed of three main software blocks:

  1. Sensor Device. It performs image acquisition, runs a cv algorithm and sends the results to the coordinator;
  2. Coordinator Device. Allows the user to communicate with the device, performing configuration tasks, and sends algorithm results to the user;
  3. 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.

Demo Setup

note html_m79111981 

 


 

Hardware Requirements.

 

  1. 2 PIC32 Seed Eye Boards
  2. Camera Board with HV7131GP camera
  3. 1 Microchip programming interface (ICD3 or PICkit)
  4. Ethernet cable


Software Requirements.

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:

http://erika.tuxfamily.org/wiki/index.php?title=Main_Page
http://erika.tuxfamily.org/wiki/index.php?title=Tutorial:_Installing_ERIKA_and_RT-Druid_on_a_Linux_host


Once installed move (or link) uCV folder to Erika Contrib Folder

.../ee_base/contrib/uCV


To display and convert the images received from the sensors the following Python package is used: PIL Python Imaging Library

http://www.pythonware.com/products/pil/

 


 

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

$ make


Set Timestamp

$ ./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

listening...

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:

  1. the sensor id;
  2. the number of slot monitored;
  3. 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

Coordinator can be in three different states:

  • Init.
  • Running
  • Maintenance


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


Image Transfer

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.


ROI configuration


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:

 

  1. background invalid (Background empty or wrong) - code 0;
  2. background valid (Background good and valid) - code 1;
  3. 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:

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:

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.

Credits

  • Daniele Alessandrelli
  • Andrea Azzarà
  • Bernardo Dal Seno
  • Massimo Magrini
  • Davide Moroni
  • Gabriele Pieri
  • Ovidio Salvetti