Skip to content

Commit

Permalink
Allowing to use any pixel format in FeatureDetector::determineHarrisP…
Browse files Browse the repository at this point in the history
…oints()

Summary: $title

Reviewed By: enpe

Differential Revision: D63717078

fbshipit-source-id: 66e6bcb49ff6e8aa968a7474004ed71c84fe4100
  • Loading branch information
janherling authored and facebook-github-bot committed Oct 2, 2024
1 parent 0c8ac3b commit 70ec67f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
14 changes: 14 additions & 0 deletions impl/ocean/cv/detector/FeatureDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ Vectors2 FeatureDetector::determineHarrisPoints(const uint8_t* yFrame, const uns
return Detector::HarrisCorner::corners2imagePoints(cornersSubRegion);
}

Vectors2 FeatureDetector::determineHarrisPoints(const Frame& frame, const SubRegion& subRegion, const unsigned int horizontalBins, const unsigned int verticalBins, const unsigned int strength, Worker* worker, std::vector<int>* strengths)
{
ocean_assert(frame.isValid());

Frame yFrame;
if (!CV::FrameConverter::Comfort::convert(frame, FrameType::FORMAT_Y8, yFrame, CV::FrameConverter::CP_AVOID_COPY_IF_POSSIBLE, worker))
{
ocean_assert(false && "Invalid pixel format!");
return Vectors2();
}

return determineHarrisPoints(yFrame.constdata<uint8_t>(), yFrame.width(), yFrame.height(), yFrame.paddingElements(), subRegion, horizontalBins, verticalBins, strength, worker, strengths);
}

}

}
Expand Down
21 changes: 5 additions & 16 deletions impl/ocean/cv/detector/FeatureDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class OCEAN_CV_DETECTOR_EXPORT FeatureDetector

/**
* Creates a new intensity vector object with undefined vector elements.
* Beware: The elemtns are neither zero nor a specific value!
* Beware: The elements are neither zero nor a specific value!
* @see VectorT2::VectorT2()
*/
inline IntensityVector2();

/**
* Creates a new intensity vector by the given postion and intensity value.
* Creates a new intensity vector by the given position and intensity value.
* @param position Vector position
* @param intensity Vector intensity
*/
Expand Down Expand Up @@ -84,7 +84,7 @@ class OCEAN_CV_DETECTOR_EXPORT FeatureDetector

/**
* Determines the points in an 8bit grayscale image with highest Harris corner response votes.
* @param yFrame The 8bit grayscale frame in which the Harris corner respondes have to be determined, must be valid
* @param yFrame The 8bit grayscale frame in which the Harris corner responses have to be determined, must be valid
* @param width The width of the frame in pixel, with range [5, infinity)
* @param height The height of the frame in pixel, with range [5, infinity)
* @param yFramePaddingElements The number of padding elements at the end of each row of yFrame, in elements, with range [0, infinity)
Expand All @@ -99,7 +99,7 @@ class OCEAN_CV_DETECTOR_EXPORT FeatureDetector

/**
* Determines strong feature points in a given image, optional a sub-region can be specified in that the points are detected.
* @param yFrame The frame in which the feature points are detected, must have pixel format FORMAT_Y, must be valid
* @param frame The frame in which the feature points are detected, will be converted to a frame with pixel format FORMAT_Y internally, must be valid
* @param subRegion Optional sub-region specifying a small image area in that the points are detected, an invalid sub-region to use the entire frame
* @param horizontalBins Optional horizontal bins that can be used to distribute the tracked points into array bins (in each bin there will be at most one point)
* @param verticalBins Optional vertical bins that can be used to distribute the tracked points into array bins (in each bin there will be at most one point)
Expand All @@ -108,7 +108,7 @@ class OCEAN_CV_DETECTOR_EXPORT FeatureDetector
* @param strengths Optional resulting strength values individual for each point
* @return The resulting feature points, feature points with high strength value first
*/
static inline Vectors2 determineHarrisPoints(const Frame& yFrame, const SubRegion& subRegion = SubRegion(), const unsigned int horizontalBins = 0u, const unsigned int verticalBins = 0u, const unsigned int strength = 30u, Worker* worker = nullptr, std::vector<int>* strengths = nullptr);
static Vectors2 determineHarrisPoints(const Frame& frame, const SubRegion& subRegion = SubRegion(), const unsigned int horizontalBins = 0u, const unsigned int verticalBins = 0u, const unsigned int strength = 30u, Worker* worker = nullptr, std::vector<int>* strengths = nullptr);

/**
* Determines strong feature points in a given image, optional a sub-region can be specified in that the points are detected.
Expand Down Expand Up @@ -151,17 +151,6 @@ inline bool FeatureDetector::IntensityVector2::operator<(const IntensityVector2&
return vectorIntensity > object.vectorIntensity;
}

inline Vectors2 FeatureDetector::determineHarrisPoints(const Frame& yFrame, const SubRegion& subRegion, const unsigned int horizontalBins, const unsigned int verticalBins, const unsigned int strength, Worker* worker, std::vector<int>* strengths)
{
if (!yFrame.isPixelFormatCompatible(FrameType::FORMAT_Y8))
{
ocean_assert(false && "Invalid pixel format!");
return Vectors2();
}

return determineHarrisPoints(yFrame.constdata<uint8_t>(), yFrame.width(), yFrame.height(), yFrame.paddingElements(), subRegion, horizontalBins, verticalBins, strength, worker, strengths);
}

}

}
Expand Down

0 comments on commit 70ec67f

Please sign in to comment.