MPEG CDVA Experimentation Model (CXM)  1.0
Compact Descriptors for Visual Analisys
CompressedFeatureList.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 "FeatureList.h"
16 
17 #include "DescriptorTimeMap.h"
18 #include "CdvaException.h"
19 
20 #include <iostream>
21 
22 namespace mpeg7cdva
23 {
24 
25 class CoordList {
26 
27 
28 public:
29  CoordList() {}
30  CoordList(mpeg7cdvs::FeatureList& fl);
31 
32  virtual unsigned int getX(int i) = 0;
33  virtual unsigned int getY(int i) = 0;
34 
35 };
36 
37 class WrappedCoordList : public CoordList {
38 protected:
39  mpeg7cdvs::FeatureList& mfl;
40 
41 
42  virtual unsigned int clampIdx(unsigned int i) {
43  if (i >= mfl.nFeatures()) {
44  return 0;
45  }
46  else return i;
47  }
48 
49 public:
50  WrappedCoordList(mpeg7cdvs::FeatureList& fl) : mfl(fl) {}
51 
52  virtual unsigned int getX(int i) { assert(i < mfl.nFeatures()); return mfl.features[i].x; };
53  virtual unsigned int getY(int i) { assert(i < mfl.nFeatures()); return mfl.features[i].y; };
54 };
55 
56 class LeanCoordList : public CoordList{
57 protected:
58  unsigned int* xCoord;
59  unsigned int* yCoord;
60  int nFeatures;
61 
62 public:
63  LeanCoordList();
64 
65  LeanCoordList(int size);
66 
67  LeanCoordList(mpeg7cdvs::FeatureList& fl);
68 
69  LeanCoordList(const LeanCoordList& other);
70 
71  LeanCoordList & operator= (const LeanCoordList & other);
72 
73  virtual ~LeanCoordList();
74 
75  virtual unsigned int getX(int i) { return xCoord[i]; };
76  virtual unsigned int getY(int i) { return yCoord[i]; };
77 
78  virtual void setX(int i, unsigned int x) { xCoord[i]=x; };
79  virtual void setY(int i, unsigned int y) { yCoord[i]=y; };
80 
81  virtual int getLength() { return nFeatures; }
82 
83  virtual mpeg7cdvs::FeatureList& getFeatureList();
84 
85  virtual void getFeatureList(mpeg7cdvs::FeatureList& fl);
86 };
87 
88 class CompressedFeatureList : public mpeg7cdvs::CompressedFeatureList {
89 
90 public:
91 
93 
94  CompressedFeatureList(const CompressedFeatureList& a, bool relevantOnly=false);
95 
96 
97  CompressedFeatureList(const mpeg7cdvs::FeatureList & a, bool relevantOnly);
98 
100 
101  CompressedFeatureList & operator=(mpeg7cdvs::CompressedFeatureList a);
102 
103  void toCDVScfl(mpeg7cdvs::CompressedFeatureList& cfl);
104 
105  void allocate(int nFeatures, int descLen);
106 
107  virtual int matchDescriptors_oneWay(mpeg7cdvs::PointPairs &pairs, const CompressedFeatureList & otherFeatureList, float ratioThreshold,
108  DescriptorTimeMap& thisDtm, DescriptorTimeMap& otherDtm, CoordList& thisFl, CoordList& otherFl, int thisIdx, int otherIdx, int** distanceMatrix) const;
109 
110  virtual int matchDescriptors_twoWay(mpeg7cdvs::PointPairs &pairs, const CompressedFeatureList &otherFeatureList, float ratioThreshold,
111  DescriptorTimeMap& thisDtm, DescriptorTimeMap& otherDtm, CoordList& thisFl, CoordList& otherFl, int thisIdx, int otherIdx, int** distanceMatrix) const;
112 
113  void getFeatureList(mpeg7cdvs::FeatureList& fl);
114 
115  std::vector<int> relevances;
116 };
117 
118 
119 } // end of namespace
std::vector< int > relevances
Definition: CompressedFeatureList.h:115
virtual unsigned int getY(int i)
Definition: CompressedFeatureList.h:53
Definition: CompressedFeatureList.h:56
Definition: CompressedFeatureList.h:88
virtual unsigned int getY(int i)
Definition: CompressedFeatureList.h:76
unsigned int * yCoord
Definition: CompressedFeatureList.h:59
Definition: DescriptorTimeMap.h:24
Namespace used to encapsulate all MPEG-7 CDVA declarations.
Definition: Buffer.h:14
virtual void setX(int i, unsigned int x)
Definition: CompressedFeatureList.h:78
mpeg7cdvs::FeatureList & mfl
Definition: CompressedFeatureList.h:39
int nFeatures
Definition: CompressedFeatureList.h:60
CoordList()
Definition: CompressedFeatureList.h:29
virtual unsigned int getX(int i)
Definition: CompressedFeatureList.h:75
Definition: CompressedFeatureList.h:37
virtual unsigned int clampIdx(unsigned int i)
Definition: CompressedFeatureList.h:42
WrappedCoordList(mpeg7cdvs::FeatureList &fl)
Definition: CompressedFeatureList.h:50
Definition: CompressedFeatureList.h:25
virtual int getLength()
Definition: CompressedFeatureList.h:81
virtual void setY(int i, unsigned int y)
Definition: CompressedFeatureList.h:79
virtual unsigned int getX(int i)
Definition: CompressedFeatureList.h:52
virtual unsigned int getY(int i)=0
virtual unsigned int getX(int i)=0
unsigned int * xCoord
Definition: CompressedFeatureList.h:58