MPEG CDVA Experimentation Model (CXM)  1.0
Compact Descriptors for Visual Analisys
RefFeature.h
Go to the documentation of this file.
1 /*
2 The copyright in this software is being made available under this MPEG Reference Software Copyright License. This software may be subject to other third party and contributor rights, including patent rights, and no such rights are granted under this license.
3 
4 Copyright (c) 2016-2017, Joanneum Research, Mitsubishi Electric Research Labs, Peking University, Telecom Italia, University of Surrey, Visual Atoms
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 * Neither the names of Joanneum Research, Mitsubishi Electric Research Labs, Peking University, Telecom Italia, University of Surrey, Visual Atoms nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 */
12 
13 #pragma once
14 
15 #include <stdio.h>
16 #include <string.h>
17 
18 #include "Feature.h"
19 
20 namespace mpeg7cdva {
21 
22  class RefFeature : public mpeg7cdvs::Feature {
23  public:
24  // overlapping with Feature
25 
26  int refFrame;
28  int diff;
29  int descrDiff[descrLength];
30  char compressed[descrLength >> 2];
31  bool refOnly;
32  std::vector<unsigned int> timesPresent;
33 
34 
35  RefFeature(mpeg7cdvs::Feature& other) {
36  // copy members
37  x = other.x;
38  y = other.y;
39  scale = other.scale;
40  orientation = other.orientation;
41  peak = other.peak;
42  curvRatio = other.curvRatio;
43  curvSigma = other.curvSigma;
44  memcpy(&descr, &other.descr, 4 * descrLength);
45  pdf = other.pdf;
46  spatialIndex = other.spatialIndex;
47  relevance = other.relevance;
48  memcpy(&qdescr, &other.qdescr, 4 * descrLength);
49  octave = other.octave;
50  iscale = other.iscale;
51 
52  // init new members
53  refFeatureIndex = -1;
54  diff = 0;
55  memset(&descrDiff, 0, 4 * descrLength);
56  refOnly = false;
57 
58  compress();
59 
60  }
61 
62  void compress() {
63  unsigned char uc;
64  int nof_elements = descrLength;
65  int byte_offset = 0;
66  int descr_bytes = 0;
67  for (int i = 0; i < nof_elements; i++)
68  {
69  if (byte_offset == 0)
70  {
71  uc = 0;
72  }
73  int val = qdescr[i];
74  if (val == 2) val = 3;
75  uc |= (val & 3) << byte_offset;
76  byte_offset += 2;
77  if (byte_offset == 8)
78  {
79  compressed[descr_bytes] = uc;
80  byte_offset = 0;
81  // go to next byte;
82  descr_bytes++;
83  }
84  }
85  }
86  };
87 
88 
89 }
char compressed[descrLength >> 2]
Definition: RefFeature.h:30
int refFrame
Definition: RefFeature.h:26
bool refOnly
Definition: RefFeature.h:31
int descrDiff[descrLength]
Definition: RefFeature.h:29
Namespace used to encapsulate all MPEG-7 CDVA declarations.
Definition: Buffer.h:14
std::vector< unsigned int > timesPresent
Definition: RefFeature.h:32
int diff
Definition: RefFeature.h:28
RefFeature(mpeg7cdvs::Feature &other)
Definition: RefFeature.h:35
int refFeatureIndex
Definition: RefFeature.h:27
Definition: RefFeature.h:22
void compress()
Definition: RefFeature.h:62