* TIFF Library UNIX-specific Routines.
*/
#include "tiffiop.h"
+#include "tiffio.hxx"
#include <iostream>
#ifndef __VMS
int binIdx = featComponent % N_BINS;\r
int cellIdx = featComponent / N_BINS;\r
\r
- const float *hist = _hists[binIdx].ptr<float>((int)y);\r
- res = hist[fastRect[cellIdx].p0] - hist[fastRect[cellIdx].p1] - hist[fastRect[cellIdx].p2] + hist[fastRect[cellIdx].p3];\r
+ const float *phist = _hists[binIdx].ptr<float>((int)y);\r
+ res = phist[fastRect[cellIdx].p0] - phist[fastRect[cellIdx].p1] - phist[fastRect[cellIdx].p2] + phist[fastRect[cellIdx].p3];\r
\r
- const float *normSum = _normSum.ptr<float>((int)y);\r
- normFactor = (float)(normSum[fastRect[0].p0] - normSum[fastRect[1].p1] - normSum[fastRect[2].p2] + normSum[fastRect[3].p3]);\r
+ const float *pnormSum = _normSum.ptr<float>((int)y);\r
+ normFactor = (float)(pnormSum[fastRect[0].p0] - pnormSum[fastRect[1].p1] - pnormSum[fastRect[2].p2] + pnormSum[fastRect[3].p3]);\r
res = (res > 0.001f) ? ( res / (normFactor + 0.001f) ) : 0.f; //for cutting negative values, which apper due to floating precision\r
\r
return res;\r
inline uchar CvLBPEvaluator::Feature::calc(const Mat &_sum, size_t y) const
{
- const int* sum = _sum.ptr<int>((int)y);
- int cval = sum[p[5]] - sum[p[6]] - sum[p[9]] + sum[p[10]];
-
- return (uchar)((sum[p[0]] - sum[p[1]] - sum[p[4]] + sum[p[5]] >= cval ? 128 : 0) | // 0
- (sum[p[1]] - sum[p[2]] - sum[p[5]] + sum[p[6]] >= cval ? 64 : 0) | // 1
- (sum[p[2]] - sum[p[3]] - sum[p[6]] + sum[p[7]] >= cval ? 32 : 0) | // 2
- (sum[p[6]] - sum[p[7]] - sum[p[10]] + sum[p[11]] >= cval ? 16 : 0) | // 5
- (sum[p[10]] - sum[p[11]] - sum[p[14]] + sum[p[15]] >= cval ? 8 : 0) | // 8
- (sum[p[9]] - sum[p[10]] - sum[p[13]] + sum[p[14]] >= cval ? 4 : 0) | // 7
- (sum[p[8]] - sum[p[9]] - sum[p[12]] + sum[p[13]] >= cval ? 2 : 0) | // 6
- (sum[p[4]] - sum[p[5]] - sum[p[8]] + sum[p[9]] >= cval ? 1 : 0)); // 3
+ const int* psum = _sum.ptr<int>((int)y);
+ int cval = psum[p[5]] - psum[p[6]] - psum[p[9]] + psum[p[10]];
+
+ return (uchar)((psum[p[0]] - psum[p[1]] - psum[p[4]] + psum[p[5]] >= cval ? 128 : 0) | // 0
+ (psum[p[1]] - psum[p[2]] - psum[p[5]] + psum[p[6]] >= cval ? 64 : 0) | // 1
+ (psum[p[2]] - psum[p[3]] - psum[p[6]] + psum[p[7]] >= cval ? 32 : 0) | // 2
+ (psum[p[6]] - psum[p[7]] - psum[p[10]] + psum[p[11]] >= cval ? 16 : 0) | // 5
+ (psum[p[10]] - psum[p[11]] - psum[p[14]] + psum[p[15]] >= cval ? 8 : 0) | // 8
+ (psum[p[9]] - psum[p[10]] - psum[p[13]] + psum[p[14]] >= cval ? 4 : 0) | // 7
+ (psum[p[8]] - psum[p[9]] - psum[p[12]] + psum[p[13]] >= cval ? 2 : 0) | // 6
+ (psum[p[4]] - psum[p[5]] - psum[p[8]] + psum[p[9]] >= cval ? 1 : 0)); // 3
}
#endif
float max_scale_;
public:
- SlidingWindowImageRange(int width, int height, int x_step = 3, int y_step = 3, int scales = 5, float min_scale = 0.6, float max_scale = 1.6) :
- width_(width), height_(height), x_step_(x_step),y_step_(y_step), scales_(scales), min_scale_(min_scale), max_scale_(max_scale)
+ SlidingWindowImageRange(int width, int height, int x_step = 3, int y_step = 3, int _scales = 5, float min_scale = 0.6, float max_scale = 1.6) :
+ width_(width), height_(height), x_step_(x_step),y_step_(y_step), scales_(_scales), min_scale_(min_scale), max_scale_(max_scale)
{
}
LocationImageRange& operator=(const LocationImageRange&);
public:
- LocationImageRange(const std::vector<Point>& locations, int scales = 5, float min_scale = 0.6, float max_scale = 1.6) :
- locations_(locations), scales_(scales), min_scale_(min_scale), max_scale_(max_scale)
+ LocationImageRange(const std::vector<Point>& locations, int _scales = 5, float min_scale = 0.6, float max_scale = 1.6) :
+ locations_(locations), scales_(_scales), min_scale_(min_scale), max_scale_(max_scale)
{
}
LocationScaleImageRange(const LocationScaleImageRange&);
LocationScaleImageRange& operator=(const LocationScaleImageRange&);
public:
- LocationScaleImageRange(const std::vector<Point>& locations, const std::vector<float>& scales) :
- locations_(locations), scales_(scales)
+ LocationScaleImageRange(const std::vector<Point>& locations, const std::vector<float>& _scales) :
+ locations_(locations), scales_(_scales)
{
- assert(locations.size()==scales.size());
+ assert(locations.size()==_scales.size());
}
ImageIterator* iterator() const
std::vector<Template*> templates;
public:
- Matching(bool use_orientation = true, float truncate = 10) : truncate_(truncate), use_orientation_(use_orientation)
+ Matching(bool use_orientation = true, float _truncate = 10) : truncate_(_truncate), use_orientation_(use_orientation)
{
}
LocationImageIterator& operator=(const LocationImageIterator&);
public:
- LocationImageIterator(const std::vector<Point>& locations, int scales, float min_scale, float max_scale);
+ LocationImageIterator(const std::vector<Point>& locations, int _scales, float min_scale, float max_scale);
bool hasNext() const {
return has_next_;
LocationScaleImageIterator& operator=(const LocationScaleImageIterator&);
public:
- LocationScaleImageIterator(const std::vector<Point>& locations, const std::vector<float>& scales) :
- locations_(locations), scales_(scales)
+ LocationScaleImageIterator(const std::vector<Point>& locations, const std::vector<float>& _scales) :
+ locations_(locations), scales_(_scales)
{
- assert(locations.size()==scales.size());
+ assert(locations.size()==_scales.size());
reset();
}
int height,
int x_step = 3,
int y_step = 3,
- int scales = 5,
+ int _scales = 5,
float min_scale = 0.6,
float max_scale = 1.6) :
height_(height),
x_step_(x_step),
y_step_(y_step),
- scales_(scales),
+ scales_(_scales),
min_scale_(min_scale),
max_scale_(max_scale)
{
ChamferMatcher::LocationImageIterator::LocationImageIterator(const std::vector<Point>& locations,
- int scales = 5,
+ int _scales = 5,
float min_scale = 0.6,
float max_scale = 1.6) :
locations_(locations),
- scales_(scales),
+ scales_(_scales),
min_scale_(min_scale),
max_scale_(max_scale)
{
}
-ChamferMatcher::Matches* ChamferMatcher::Matching::matchTemplates(Mat& dist_img, Mat& orientation_img, const ImageRange& range, float orientation_weight)
+ChamferMatcher::Matches* ChamferMatcher::Matching::matchTemplates(Mat& dist_img, Mat& orientation_img, const ImageRange& range, float _orientation_weight)
{
- ChamferMatcher::Matches* matches(new Matches());
+ ChamferMatcher::Matches* pmatches(new Matches());
// try each template
for(size_t i = 0; i < templates.size(); i++) {
ImageIterator* it = range.iterator();
if (loc.x-tpl->center.x<0 || loc.x+tpl->size.width/2>=dist_img.cols) continue;
if (loc.y-tpl->center.y<0 || loc.y+tpl->size.height/2>=dist_img.rows) continue;
- ChamferMatcher::Match* is = localChamferDistance(loc, dist_img, orientation_img, tpl, orientation_weight);
+ ChamferMatcher::Match* is = localChamferDistance(loc, dist_img, orientation_img, tpl, _orientation_weight);
if(is)
{
- matches->push_back(*is);
+ pmatches->push_back(*is);
delete is;
}
}
delete it;
}
- return matches;
+ return pmatches;
}
* @param edge_img Edge image
* @return a match object
*/
-ChamferMatcher::Matches* ChamferMatcher::Matching::matchEdgeImage(Mat& edge_img, const ImageRange& range, float orientation_weight, int /*max_matches*/, float /*min_match_distance*/)
+ChamferMatcher::Matches* ChamferMatcher::Matching::matchEdgeImage(Mat& edge_img, const ImageRange& range,
+ float _orientation_weight, int /*max_matches*/, float /*min_match_distance*/)
{
CV_Assert(edge_img.channels()==1);
// Template matching
- ChamferMatcher::Matches* matches = matchTemplates( dist_img,
+ ChamferMatcher::Matches* pmatches = matchTemplates( dist_img,
orientation_img,
range,
- orientation_weight);
+ _orientation_weight);
if (use_orientation_) {
dist_img.release();
annotated_img.release();
- return matches;
+ return pmatches;
}
//! detects corners using FAST algorithm by E. Rosten
CV_EXPORTS void FAST( InputArray image, CV_OUT vector<KeyPoint>& keypoints,
- int threshold, bool nonmaxSupression=true, int type = 2 );
+ int threshold, bool nonmaxSupression=true );
+
+CV_EXPORTS void FAST( InputArray image, CV_OUT vector<KeyPoint>& keypoints,
+ int threshold, bool nonmaxSupression, int type );
class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector
{
break;
}
}
+
+void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression)
+{
+ FAST(_img, keypoints, threshold, nonmax_suppression, FastFeatureDetector::TYPE_9_16);
+}
/*
* FastFeatureDetector
*/
case HALF_SIZE:\r
if (i > map_x.cols*0.25 && i < map_x.cols*0.75 && j > map_x.rows*0.25 && j < map_x.rows*0.75)\r
{\r
- map_x.at<float>(j,i) = 2 * (i - map_x.cols * 0.25f) + 0.5f;\r
- map_y.at<float>(j,i) = 2 * (j - map_x.rows * 0.25f) + 0.5f;\r
+ map_x.at<float>(j,i) = 2.f * (i - map_x.cols * 0.25f) + 0.5f;\r
+ map_y.at<float>(j,i) = 2.f * (j - map_x.rows * 0.25f) + 0.5f;\r
}\r
else\r
{\r
- map_x.at<float>(j,i) = 0;\r
- map_y.at<float>(j,i) = 0;\r
+ map_x.at<float>(j,i) = 0.f;\r
+ map_y.at<float>(j,i) = 0.f;\r
}\r
break;\r
case UPSIDE_DOWN:\r
struct InInterval
{
- InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {};
+ InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {}
const int lo, hi;
bool operator() (const unsigned char a, const unsigned char b) const
if (ret < 0)
{
- if (ret == (int64_t)AVERROR_EOF)
+ if ((int64_t)ret == (int64_t)AVERROR_EOF)
*endOfFile = true;
return false;
}
{
int sum = 0;
const int* v = vectors + i*m;
- labels[i] = i < k ? i : (*r)(k);
+ labels[i] = i < k ? i : r->uniform(0, k);
// compute weight of each vector
for( j = 0; j < m; j++ )
p[2][0] = p[2][1] = p[2][2] = p[2][3] = 0;
}
-inline float HaarEvaluator::Feature :: calc( int offset ) const
+inline float HaarEvaluator::Feature :: calc( int _offset ) const
{
- float ret = rect[0].weight * CALC_SUM(p[0], offset) + rect[1].weight * CALC_SUM(p[1], offset);
+ float ret = rect[0].weight * CALC_SUM(p[0], _offset) + rect[1].weight * CALC_SUM(p[1], _offset);
if( rect[2].weight != 0.0f )
- ret += rect[2].weight * CALC_SUM(p[2], offset);
+ ret += rect[2].weight * CALC_SUM(p[2], _offset);
return ret;
}
-inline void HaarEvaluator::Feature :: updatePtrs( const Mat& sum )
+inline void HaarEvaluator::Feature :: updatePtrs( const Mat& _sum )
{
- const int* ptr = (const int*)sum.data;
- size_t step = sum.step/sizeof(ptr[0]);
+ const int* ptr = (const int*)_sum.data;
+ size_t step = _sum.step/sizeof(ptr[0]);
if (tilted)
{
CV_TILTED_PTRS( p[0][0], p[0][1], p[0][2], p[0][3], ptr, rect[0].r, step );
p[i] = 0;
}
-inline int LBPEvaluator::Feature :: calc( int offset ) const
+inline int LBPEvaluator::Feature :: calc( int _offset ) const
{
- int cval = CALC_SUM_( p[5], p[6], p[9], p[10], offset );
-
- return (CALC_SUM_( p[0], p[1], p[4], p[5], offset ) >= cval ? 128 : 0) | // 0
- (CALC_SUM_( p[1], p[2], p[5], p[6], offset ) >= cval ? 64 : 0) | // 1
- (CALC_SUM_( p[2], p[3], p[6], p[7], offset ) >= cval ? 32 : 0) | // 2
- (CALC_SUM_( p[6], p[7], p[10], p[11], offset ) >= cval ? 16 : 0) | // 5
- (CALC_SUM_( p[10], p[11], p[14], p[15], offset ) >= cval ? 8 : 0)| // 8
- (CALC_SUM_( p[9], p[10], p[13], p[14], offset ) >= cval ? 4 : 0)| // 7
- (CALC_SUM_( p[8], p[9], p[12], p[13], offset ) >= cval ? 2 : 0)| // 6
- (CALC_SUM_( p[4], p[5], p[8], p[9], offset ) >= cval ? 1 : 0);
+ int cval = CALC_SUM_( p[5], p[6], p[9], p[10], _offset );
+
+ return (CALC_SUM_( p[0], p[1], p[4], p[5], _offset ) >= cval ? 128 : 0) | // 0
+ (CALC_SUM_( p[1], p[2], p[5], p[6], _offset ) >= cval ? 64 : 0) | // 1
+ (CALC_SUM_( p[2], p[3], p[6], p[7], _offset ) >= cval ? 32 : 0) | // 2
+ (CALC_SUM_( p[6], p[7], p[10], p[11], _offset ) >= cval ? 16 : 0) | // 5
+ (CALC_SUM_( p[10], p[11], p[14], p[15], _offset ) >= cval ? 8 : 0)| // 8
+ (CALC_SUM_( p[9], p[10], p[13], p[14], _offset ) >= cval ? 4 : 0)| // 7
+ (CALC_SUM_( p[8], p[9], p[12], p[13], _offset ) >= cval ? 2 : 0)| // 6
+ (CALC_SUM_( p[4], p[5], p[8], p[9], _offset ) >= cval ? 1 : 0);
}
-inline void LBPEvaluator::Feature :: updatePtrs( const Mat& sum )
+inline void LBPEvaluator::Feature :: updatePtrs( const Mat& _sum )
{
- const int* ptr = (const int*)sum.data;
- size_t step = sum.step/sizeof(ptr[0]);
+ const int* ptr = (const int*)_sum.data;
+ size_t step = _sum.step/sizeof(ptr[0]);
Rect tr = rect;
CV_SUM_PTRS( p[0], p[1], p[4], p[5], ptr, tr, step );
tr.x += 2*rect.width;
featComponent = 0;
}
-inline float HOGEvaluator::Feature :: calc( int offset ) const
+inline float HOGEvaluator::Feature :: calc( int _offset ) const
{
- float res = CALC_SUM(pF, offset);
- float normFactor = CALC_SUM(pN, offset);
+ float res = CALC_SUM(pF, _offset);
+ float normFactor = CALC_SUM(pN, _offset);
res = (res > 0.001f) ? (res / ( normFactor + 0.001f) ) : 0.f;
return res;
}
{\r
pair<float, int> opt = *min_element(steps, steps + nsteps);\r
cost(y, x) = opt.first;\r
- control(y, x) = opt.second;\r
+ control(y, x) = (uchar)opt.second;\r
reachable(y, x) = 255;\r
}\r
}\r
{\r
pair<float, int> opt = *min_element(steps, steps + nsteps);\r
cost(y, x) = opt.first;\r
- control(y, x) = opt.second;\r
+ control(y, x) = (uchar)opt.second;\r
reachable(y, x) = 255;\r
}\r
}\r
if (updateBackgroundModel_)
{
for (int i = 0; i < nfeatures; ++i)
- weights[i] *= 1.0f - learningRate_;
+ weights[i] *= (float)(1.0f - learningRate_);
bool inserted = insertFeature(newFeatureColor, (float)learningRate_, colors, weights, nfeatures, maxFeatures_);