Saturday, July 19, 2014

New variable $MSE, and Dynamic Print variables on IQeye cameras

An interesting "Dynamic Print" or DP variable was added to the firmware for IQ8xx and IQ7xx cameras a few releases ago.

Dynamic Print variables are those that represent internal, and possibly dynamic, camera values, and can be used in filenames on triggers, inside of image captions, and on custom webpages that you write and upload to the camera.

This particular variable is pretty cool. It is:

$MSE = Milliseconds since epoch

One of the problems I had encountered with IQeye cameras is I was only able to set up rules to name trigger images with granularity to the second. This presents the following sorting problem:



Trigger sequences are supposed to go from negative numbers to positive ones, like trig-03, trig-02,  trig-01,  trig+00,  trig+01  trig+02. However, since the date comes before the trigger sequence number in the filenames, when an event "spans seconds", where the last set of images roll over into the next second, this plays havoc on the sorting.

In addition, there is no guarantee that your filemanager will put trig-03, trig-02,  trig-01,  trig+00,  trig+01  trig+02 in order, even by themselves.

Old

i.e.
File Path "$SH/$SD(%m)-$SD(%d)/$SD(%H)"
File Name "$ST.$FN"

This gives you folders with the camera MAC, with folders then dated by month and day, then folders by the hour, and then the default filenames for the JPEGs themselves.

00_1a_22_21_48/05-19/14/14_10_39.trig-02.jpg

New

i.e.
File Path "$SH/$SD(%m)-$SD(%d)/$SD(%H)"
File Name "$ST.$MSE.$FN"

00_1a_22_21_48/05-19/14/14_10_39.1400510841748.trig-02.jpg

This makes sure that images are sorted in the real order that they were taken.

Maybe other cameras have this variable as well, give it a try!

Does not work
IQ031s 4.0/069
IQeye3 V2.8/6(080313)

Works
IQ511 V2.8/6(080313)
IQ511 V2.8/10(110128)
IQ805 V3.0/9(101130)
IQ752 V3.0/4(091112)

Other variables

$SHYour camera’s hardware address.
$SIYour camera’s IP address.
$SNYour camera’s name, as specified on the Network Settings page.
$STThe current time (in 24-hour format: HH:MM:SS, ex: 16:05:20).
$SDThe current date (ex: Wed Feb 03 2010).
$SCCompany name (e.g. IQinVision).
$SPProduct name (e.g. IQeye752).
$SVThe version of operating software on your camera.
$SMThe domain name, as specified on the Network Settings page.
$FNThe name of the file that your camera is accessing.
$MSEMilliseconds since epoch
$IMGDBGImage debug data
$O(oidNumber)Display an OID, like IP address (3.6.10) or the image focus value(1.2.25) or last trigger event time (1.3.20)
For time-based variables, you can use $SD in combination with the common strftime() UNIX time variables. Not all variables work. I may update this post to reflect that.
       %%     a literal %

       %a     locale's abbreviated weekday name (e.g., Sun)

       %A     locale's full weekday name (e.g., Sunday)

       %b     locale's abbreviated month name (e.g., Jan)

       %B     locale's full month name (e.g., January)

       %c     locale's date and time (e.g., Thu Mar  3 23:05:25 2005)

       %C     century; like %Y, except omit last two digits (e.g., 21)

       %d     day of month (e.g, 01)

       %D     date; same as %m/%d/%y

       %e     day of month, space padded; same as %_d

       %F     full date; same as %Y-%m-%d

       %g     last two digits of year of ISO week number (see %G)

       %G     year of ISO week number (see %V); normally useful only with %V

       %h     same as %b

       %H     hour (00..23)

       %I     hour (01..12)

       %j     day of year (001..366)

       %k     hour ( 0..23)

       %l     hour ( 1..12)

       %m     month (01..12)

       %M     minute (00..59)

       %n     a newline

       %N     nanoseconds (000000000..999999999)

       %p     locale's equivalent of either AM or PM; blank if not known

       %P     like %p, but lower case

       %r     locale's 12-hour clock time (e.g., 11:11:04 PM)

       %R     24-hour hour and minute; same as %H:%M

       %s     seconds since 1970-01-01 00:00:00 UTC

       %S     second (00..60)

       %t     a tab

       %T     time; same as %H:%M:%S

       %u     day of week (1..7); 1 is Monday

       %U     week number of year, with Sunday as first day of week (00..53)

       %V     ISO week number, with Monday as first day of week (01..53)

       %w     day of week (0..6); 0 is Sunday

       %W     week number of year, with Monday as first day of week (00..53)

       %x     locale's date representation (e.g., 12/31/99)

       %X     locale's time representation (e.g., 23:13:48)

       %y     last two digits of year (00..99)

       %Y     year

       %z     +hhmm numeric timezone (e.g., -0400)

       %:z    +hh:mm numeric timezone (e.g., -04:00)

       %::z   +hh:mm:ss numeric time zone (e.g., -04:00:00)

       %:::z  numeric  time  zone  with  :  to necessary precision (e.g., -04,
       +05:30)

       %Z     alphabetic time zone abbreviation (e.g., EDT)

Have fun!

Thursday, July 3, 2014

Embedded EXIF data in IQeye camera images

Exiftool is a PERL utility to read extra metadata from JPEG images. This metadata is often used to store things like camera attributes and even GPS data in modern consumer cameras including phone cameras.

Turns out IQeye cameras write some metadata to images.

Using EXIFtool to view JPEG metadata

$ exiftool -a 09_06_31.trig+00.jpg

Establishing Patterns

For images captured as part of a motion event (FTP'd direct from camera to NAS):

Comment                         : P..L0;exacq1400510841.748exacq
Comment                         : {"IQimage":{"sequence":529057,"time":1400510841748,"event":["motion"],"motionWindows":[2],"imgjdbg":" 291/020:20/480/005:081/107/07/4/50/70/20/17:06/07/06:d4"}}

The first comment, containing the garbage characters, is actually the MAC of the camera. Expressed in HEX, it's something like:

JPEG COM (7 bytes):
    0018: 00 50 1a 02 2c be 3b [.P..,.;]

3b is a product code. This is documented by IQinvision, and I am gathering a list of camera models.

You see that on motion events, there is some extra data after the MAC, flanked with 'exacq'.

If you noticed the curly braces, you may have thought that the second comment is JSON. You'd be right :-)

{
    "IQimage": {
        "sequence": 529057,
        "time": 1400510841748,
        "event": [
            "motion"
        ],
        "motionWindows": [
            2
        ],
        "imgjdbg": " 291/020:20/480/005:081/107/07/4/50/70/20/17:06/07/06:d4"
    }
}

Seems IQinvision has some clever engineers!

Complete Event Sequence

Here is the EXIF metadata for a complete motion event. The first 3 images are "prebuffer" as set in the camera so that we can see the lead-up to the motion event. Highlighted in green is the motion status across the sequence.

11_09_34.trig-03.jpg
Comment                         : P..L0;exacq1399046974.310exacq
Comment                         : {"IQimage":{"sequence":2315889,"time":1399046974310,"event":["none"],"imgjdbg":" 436/067:32/120/016:077/110/01/4/50/60/15/17:21/24/24:bb"}}

11_09_34.trig-02.jpg
Comment                         : P..L0;exacq1399046974.878exacq
Comment                         : {"IQimage":{"sequence":2315898,"time":1399046974878,"event":["none"],"imgjdbg":" 436/067:32/120/016:077/110/01/4/50/60/15/17:21/24/24:bb"}}

11_09_34.trig-01.jpg
Comment                         : P..L0;exacq1399046974.944exacq
Comment                         : {"IQimage":{"sequence":2315899,"time":1399046974944,"event":["none"],"imgjdbg":" 436/067:32/120/016:077/110/01/4/50/60/15/17:21/24/24:bb"}}

11_09_35.trig+00.jpg
Comment                         : P..L0;exacq1399046975.011exacq
Comment                         : {"IQimage":{"sequence":2315900,"time":1399046975011,"event":["motion"],"motionWindows":[1],"imgjdbg":" 436/067:32/120/016:077/110/01/4/50/60/15/17:21/24/24:bb"}}


The last image has the motion, and this is why the status changes. See also that the motion images include the exacq data (timecode) whereas non-motion trigger event JPEGs do not.

The fields are:
  1. sequence - Not sure what this is based on, but it increments
  2. time - precise time
  3. event - type of event (none, trigger, motion)
  4. imgjdbg - unknown

Timelapse Image Sequences

Comment                         : P..,�;
Comment                         : {"IQimage":{"sequence":2380675,"time":1402422546407,"event":["none"],"imgjdbg":" 274/020:16/960/013:083/097/01/4/50/70/20/17:08/09/07:e2"}}
Comment   

Manually Downloaded Images

So far, we've looked at images that are FTPd directly by the camera to storage, both on the periodic basis and motion event basis.

So, what happens if you download now.jpg when there is a trigger occurring in the image? In the case of using the http://camera/now.jpg feature of IQeye cameras.

Well, you also get trigger data!

$ exiftool -a now\ \(1\).jpg |grep Comment
Comment                         : P..,�;
Comment                         : {"IQimage":{"sequence":20980184,"time":1404396373253,"event":["motion"],"motionWindows":[7],"imgjdbg":" 298/016:22/480/008:085/099/01/4/55/70/20/17:06/09/06:47"}}

$ exiftool -a now\ \(2\).jpg |grep Comment
Comment                         : P..,�;
Comment                         : {"IQimage":{"sequence":20980241,"time":1404396378202,"event":["motion"],"motionWindows":[6],"imgjdbg":" 298/016:22/480/008:085/099/01/4/55/70/20/17:06/09/06:47"}}

$ exiftool -a now\ \(3\).jpg |grep Comment
Comment                         : P..,�;
Comment                         : {"IQimage":{"sequence":20980453,"time":1404396395825,"event":["motion"],"motionWindows":[6],"imgjdbg":" 298/016:22/480/008:085/099/01/4/55/70/20/17:06/09/06:47"}}

Surprisingly, none of this is documented in the IQeye reference manuals...and I've been very impressed with their customer service and documentation. I've reached out to them for some more explanation of what that imgjdbg tag is.

Tuesday, July 1, 2014

Do I have a bad imager?

This is a technical article.

Testing your imager using telnet

IQeye cameras have the capability for the user to test the imager without involving the JPEG encoding hardware. This is done by running a command in the telnet environment.

Make sure the camera is not accessible by viewers, as this will conflict with an accurate imager reading.
  1. Log into the camera over telnet, in a terminal. Set 'user' as the username, though this doesn't matter at all
    telnet <ip of camera>Username> user
  2. Escalate to the privileged user
    Local_2> set privileged
  3. Enter password "system" by default, you'll get the double-caret 
  4. Local_2>> test framerate imager36 images in 5 seconds = 7.2 fps


You should get a framerate that matches the specs on your camera.
If your frame count is 0, even after resetting the camera, the imaging board is likely bad and will need to be replaced.

Here is a picture of the back of an imaging board for an IQ7xx series camera, and the front, showing the image sensor behind the movable IR filter.

The bottom circuit board of the camera plugs in perpendicularly into the exposed connector on the back of the imager board.

The IQ752 has a sliding-style IR filter assembly.