# Using Database Images

The OI terminal can store images in a local database for later use. Images sources can be an HTTP url (which many IP cameras provide), or from a USB camera device at /dev/video. A featureID and a partID field can also be stored with the image.

# Sample OIB program

The sample program shows a webcam and stores the images to the database using Database Image components.

Sample Program

Sample Program

The sample program includes one OIB program - test_db_image_sqlite.oi. Copy this to the OI terminal to run the application.

# DB Image Write Component

The DB image write component will trigger writing a record to the database that includes featureID, partID, and the image in the imageSource property.

The component writes the image in addition to several other useful fields:

  • camID: from the image write component property
  • partID: (string) from the tag set on the write component partID property
  • featureID: (int) from the tag set on the write component featureID property
  • status: (string) status of the db write event

We can see an example of the data here by viewing the SQLite database:

DB Image Write Fields

Note

This is a screenshot of a web based SQLite viewer (opens new window). The database file was obtained by FTP'ing the /tmp/db/sqlite/oi_camera file from an OI.

# DB Image Read Component

This will display an image from the database. You must specify a query in the Data Source for this component. The query in the sample:

  SELECT
    *
  FROM
    images_from_image_capture
  ORDER BY
    __id__ DESC
  LIMIT 1
  OFFSET
    $dbIndexTag

Note

In OI versions 1.10 and older, you should put this query in the imageSource field.

Will load one image (LIMIT 1) from the table images_from_image_capture (this is specified in the DB Image Write component). We use the $dbIndexTag to pick which of the results we want (zero would be the most recent image, 1 is the previous).

Note

$dbIndexTag injects the tag value into the query.

# Test

You should be able to transfer the application to your OI terminal and test.

Last Updated: 5/25/2019, 6:09:51 PM