Welcome to mirror list, hosted at ThFree Co, Russian Federation.

detect.h « simple_pipeline « libmv « libmv « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8ddf0025e4b78f1c4c69515a1ade2caab6c5f425 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/****************************************************************************
**
** Copyright (c) 2011 libmv authors.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to
** deal in the Software without restriction, including without limitation the
** rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
** sell copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
** IN THE SOFTWARE.
**
****************************************************************************/

#ifndef LIBMV_SIMPLE_PIPELINE_DETECT_H_
#define LIBMV_SIMPLE_PIPELINE_DETECT_H_

#include <iostream>
#include <vector>

#include "libmv/base/vector.h"
#include "libmv/image/image.h"

namespace libmv {

typedef unsigned char ubyte;

// A Feature is the 2D location of a detected feature in an image.
struct Feature {
  Feature(float x, float y) : x(x), y(y) {}
  Feature(float x, float y, float score, float size)
      : x(x), y(y), score(score), size(size) {}

  // Position of the feature in pixels from top-left corner.
  // Note: Libmv detector might eventually support subpixel precision.
  float x, y;

  // An estimate of how well the feature will be tracked.
  //
  // Absolute values totally depends on particular detector type
  // used for detection. It's only guaranteed that features with
  // higher score from the same Detect() result will be tracked better.
  float score;

  // An approximate feature size in pixels.
  //
  // If the feature is approximately a 5x5 square region, then size will be 5.
  // It can be used as an initial pattern size to track the feature.
  float size;
};

struct DetectOptions {
  DetectOptions();

  // TODO(sergey): Write descriptions to each of algorithms.
  enum DetectorType {
    FAST,
    MORAVEC,
    HARRIS,
  };
  DetectorType type;

  // Margin in pixels from the image boundary.
  // No features will be detected within the margin.
  int margin;

  // Minimal distance between detected features.
  int min_distance;

  // Minimum score to add a feature. Only used by FAST detector.
  //
  // TODO(sergey): Write more detailed documentation about which
  // units this value is measured in and so on.
  int fast_min_trackness;

  // Maximum count to detect. Only used by MORAVEC detector.
  int moravec_max_count;

  // Find only features similar to this pattern. Only used by MORAVEC detector.
  //
  // This is an image patch denoted in byte array with dimensions of 16px by
  // 16px used to filter features by similarity to this patch.
  unsigned char* moravec_pattern;

  // Threshold value of the Harris function to add new featrue
  // to the result.
  double harris_threshold;
};

// Detect features on a given image using given detector options.
//
// Image could have 1-4 channels, it'll be converted to a grayscale
// by the detector function if needed.
void Detect(const FloatImage& image,
            const DetectOptions& options,
            vector<Feature>* detected_features);

std::ostream& operator<<(std::ostream& os, const Feature& feature);

}  // namespace libmv

#endif