Follow us on Facebook
Follow us on Twitter
Signalogic on LinkedIn

Home > Applications > Video > Video Analytics

Video Analytics Using CIM Accelerators

Vehicle tracking and recognition
Vehicle and foot traffic recognition and tracking. Picture credit KAIST IPSL
Car stopped in non-traffic area
Car detected in non-traffic area. Picture credit RaidNet
Surveillance video anomaly detection
Surveillance video anomaly detection. Picture credit Butler University, Information Sciences and Systems


Video analytics, also sometimes referred to as Video Content Analysis, is the capability to automatically analyze video to detect and determine temporal events not based on a single image. That description is from Wikipedia, but it might be modified to include "patterns and objects from one or more images, and temporal events from multiple images or stream of images". Without fundamental pattern recognition and object detection, video content analysis cannot occur.


Video analytics, and its underlying foundation of object and pattern recognition, has many applications, including:

Source Code Examples

Below are some video analytics source code examples, marked with CIM pragmas to accelerate compute-intensive sections of code. Note that CIM pragmas and API calls follow the OpenMP convention (highlighted in yellow below).

/* IIR Filter implementation from ffmpeg library, marked with CIM pragmas */

void ff_iir_filter(const struct FFIIRFilterCoeffs *c, struct FFIIRFilterState *s,
                   int size, const int16_t *src, int sstep, int16_t *dst, int dstep) {

int i;

   if (c->order == 4) {

      for (i=0; i<size; i+=4) {

         float in, res;

         FILTER(0, 1, 2, 3);
         FILTER(1, 2, 3, 0);
         FILTER(2, 3, 0, 1);
         FILTER(3, 0, 1, 2);
      else {

         #pragma cim parallel for num_threads 4

         for (i=0; i<size; i++) {

         int j;
         float in, res;
         in = *src * c->gain;

         for (j=0; j<c->order; j++)
           in += c->cy[j] * s->x[j];

         res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1];

         for (j=1; j<c->order>>1; j++)
           res += (s->x[j] + s->x[c->order - j]) * c->cx[j];

         for (j=0; j<c->order-1; j++)
           s->x[j] = s->x[j + 1];

         *dst = av_clip_int16(lrintf(res));

         s->x[c->order - 1] = in;

         src += sstep;
         dst += sstep;

/* Discrete Cosine Transform (DCT) implementation from ffmpeg library, marked with CIM pragmas */
static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) {

int n = 1 << ctx->nbits;
int i;
float next = data[n - 1];
float inv_n = 1.0f / n;
   #pragma cim parallel for num_threads 6

   for (i=n-2; i>=2; i-=2) {

      float val1 = data[i];
      float val2 = data[i - 1] - data[i + 1];
      float c = COS(ctx, n, i);
      float s = SIN(ctx, n, i);

      data[i] = c * val1 + s * val2;
      data[i + 1] = s * val1 - c * val2;