Commit 4e478bc0 authored by jaco's avatar jaco

BING bb sorting modified and SuBSENSE compiling error fixed

parent 88bae7be
...@@ -177,9 +177,9 @@ void ObjectnessBING::predictBBoxSII( ValStructVec<float, Vec4i> &valBoxes, const ...@@ -177,9 +177,9 @@ void ObjectnessBING::predictBBoxSII( ValStructVec<float, Vec4i> &valBoxes, const
valBoxes( i ) = valBoxes( i ) * svmIIw[0] + svmIIw[1]; valBoxes( i ) = valBoxes( i ) * svmIIw[0] + svmIIw[1];
} }
//valBoxes.sort(); //valBoxes.sort();
// Ascending order. At the top there are the values with lower // Descending order. At the top there are the values with higher
// values of ​​objectness, ie more likely to have objects in the their corresponding rectangles. // values, ie more likely to have objects in the their corresponding rectangles.
valBoxes.sort( false ); valBoxes.sort( true );
} }
// Get potential bounding boxes, each of which is represented by a Vec4i for (minX, minY, maxX, maxY). // Get potential bounding boxes, each of which is represented by a Vec4i for (minX, minY, maxX, maxY).
...@@ -481,8 +481,8 @@ bool ObjectnessBING::computeSaliencyImpl( const InputArray image, OutputArray ob ...@@ -481,8 +481,8 @@ bool ObjectnessBING::computeSaliencyImpl( const InputArray image, OutputArray ob
ValStructVec<float, Vec4i> finalBoxes; ValStructVec<float, Vec4i> finalBoxes;
getObjBndBoxesForSingleImage( image.getMat(), finalBoxes, 250 ); getObjBndBoxesForSingleImage( image.getMat(), finalBoxes, 250 );
// List of rectangles returned by objectess function in ascending order. // List of rectangles returned by objectess function in descending order.
// At the top there are the rectangles with lower values of ​​objectness, ie more // At the top there are the rectangles with higher values, ie more
// likely to have objects in them. // likely to have objects in them.
vector<Vec4i> sortedBB = finalBoxes.getSortedStructVal(); vector<Vec4i> sortedBB = finalBoxes.getSortedStructVal();
Mat( sortedBB ).copyTo( objBoundingBox ); Mat( sortedBB ).copyTo( objBoundingBox );
......
...@@ -25,9 +25,9 @@ void BackgroundSubtractorLBSP::initialize(const cv::Mat& oInitImg) { ...@@ -25,9 +25,9 @@ void BackgroundSubtractorLBSP::initialize(const cv::Mat& oInitImg) {
this->initialize(oInitImg,std::vector<cv::KeyPoint>()); this->initialize(oInitImg,std::vector<cv::KeyPoint>());
} }
cv::AlgorithmInfo* BackgroundSubtractorLBSP::info() const { //cv::AlgorithmInfo* BackgroundSubtractorLBSP::info() const {
return nullptr; // //return nullptr;
} //}
void BackgroundSubtractorLBSP::getBackgroundDescriptorsImage(cv::OutputArray backgroundDescImage) const { void BackgroundSubtractorLBSP::getBackgroundDescriptorsImage(cv::OutputArray backgroundDescImage) const {
CV_Assert(LBSP::DESC_SIZE==2); CV_Assert(LBSP::DESC_SIZE==2);
......
#pragma once #pragma once
#include <opencv2/features2d.hpp> #include <opencv2/features2d.hpp>
#include <opencv2/video/background_segm.hpp> //#include <opencv2/video/background_segm.hpp>
#include "LBSP.h" #include "LBSP.h"
/*! /*!
Local Binary Similarity Pattern (LBSP) foreground-background segmentation algorithm (abstract version). Local Binary Similarity Pattern (LBSP) foreground-background segmentation algorithm (abstract version).
For more details on the different parameters, see P.-L. St-Charles and G.-A. Bilodeau, "Improving Background For more details on the different parameters, see P.-L. St-Charles and G.-A. Bilodeau, "Improving Background
Subtraction using Local Binary Similarity Patterns", in WACV 2014, or G.-A. Bilodeau et al, "Change Detection Subtraction using Local Binary Similarity Patterns", in WACV 2014, or G.-A. Bilodeau et al, "Change Detection
in Feature Space Using Local Binary Similarity Patterns", in CRV 2013. in Feature Space Using Local Binary Similarity Patterns", in CRV 2013.
This algorithm is currently NOT thread-safe. This algorithm is currently NOT thread-safe.
*/ */
class BackgroundSubtractorLBSP /* : public cv::BackgroundSubtractor */ { class BackgroundSubtractorLBSP /* : public cv::BackgroundSubtractor */
public: {
//! full constructor public:
BackgroundSubtractorLBSP(float fRelLBSPThreshold, size_t nDescDistThreshold, size_t nLBSPThresholdOffset=0); //! full constructor
//! default destructor BackgroundSubtractorLBSP( float fRelLBSPThreshold, size_t nDescDistThreshold, size_t nLBSPThresholdOffset = 0 );
virtual ~BackgroundSubtractorLBSP(); //! default destructor
//! (re)initiaization method; needs to be called before starting background subtraction virtual ~BackgroundSubtractorLBSP();
virtual void initialize(const cv::Mat& oInitImg); //! (re)initiaization method; needs to be called before starting background subtraction
//! (re)initiaization method; needs to be called before starting background subtraction (note: also reinitializes the keypoints vector) virtual void initialize( const cv::Mat& oInitImg );
virtual void initialize(const cv::Mat& oInitImg, const std::vector<cv::KeyPoint>& voKeyPoints)=0; //! (re)initiaization method; needs to be called before starting background subtraction (note: also reinitializes the keypoints vector)
//! primary model update function; the learning param is used to override the internal learning speed (ignored when <= 0) virtual void initialize( const cv::Mat& oInitImg, const std::vector<cv::KeyPoint>& voKeyPoints )=0;
virtual void operator()(cv::InputArray image, cv::OutputArray fgmask, double learningRate=0)=0; //! primary model update function; the learning param is used to override the internal learning speed (ignored when <= 0)
//! unused, always returns nullptr virtual void operator()( cv::InputArray image, cv::OutputArray fgmask, double learningRate = 0 )=0;
virtual cv::AlgorithmInfo* info() const; //! unused, always returns nullptr
//! returns a copy of the latest reconstructed background descriptors image cv::AlgorithmInfo* info() const;
virtual void getBackgroundDescriptorsImage(cv::OutputArray backgroundDescImage) const; //! returns a copy of the latest reconstructed background descriptors image
//! returns the keypoints list used for descriptor extraction (note: by default, these are generated from the DenseFeatureDetector class, and the border points are removed) virtual void getBackgroundDescriptorsImage( cv::OutputArray backgroundDescImage ) const;
virtual std::vector<cv::KeyPoint> getBGKeyPoints() const; //! returns the keypoints list used for descriptor extraction (note: by default, these are generated from the DenseFeatureDetector class, and the border points are removed)
//! sets the keypoints to be used for descriptor extraction, effectively setting the BGModel ROI (note: this function will remove all border keypoints) virtual std::vector<cv::KeyPoint> getBGKeyPoints() const;
virtual void setBGKeyPoints(std::vector<cv::KeyPoint>& keypoints); //! sets the keypoints to be used for descriptor extraction, effectively setting the BGModel ROI (note: this function will remove all border keypoints)
virtual void setBGKeyPoints( std::vector<cv::KeyPoint>& keypoints );
// ######## DEBUG PURPOSES ONLY ########## // ######## DEBUG PURPOSES ONLY ##########
int nDebugCoordX, nDebugCoordY; int nDebugCoordX, nDebugCoordY;
protected: protected:
//! background model descriptors samples (tied to m_voKeyPoints but shaped like the input frames) //! background model descriptors samples (tied to m_voKeyPoints but shaped like the input frames)
std::vector<cv::Mat> m_voBGDescSamples; std::vector<cv::Mat> m_voBGDescSamples;
//! background model keypoints used for LBSP descriptor extraction (specific to the input image size) //! background model keypoints used for LBSP descriptor extraction (specific to the input image size)
std::vector<cv::KeyPoint> m_voKeyPoints; std::vector<cv::KeyPoint> m_voKeyPoints;
//! defines the current number of used keypoints (always tied to m_voKeyPoints) //! defines the current number of used keypoints (always tied to m_voKeyPoints)
size_t m_nKeyPoints; size_t m_nKeyPoints;
//! input image size //! input image size
cv::Size m_oImgSize; cv::Size m_oImgSize;
//! input image channel size //! input image channel size
size_t m_nImgChannels; size_t m_nImgChannels;
//! input image type //! input image type
int m_nImgType; int m_nImgType;
//! absolute descriptor distance threshold //! absolute descriptor distance threshold
const size_t m_nDescDistThreshold; const size_t m_nDescDistThreshold;
//! LBSP internal threshold offset value -- used to reduce texture noise in dark regions //! LBSP internal threshold offset value -- used to reduce texture noise in dark regions
const size_t m_nLBSPThresholdOffset; const size_t m_nLBSPThresholdOffset;
//! LBSP relative internal threshold (kept here since we don't keep an LBSP object) //! LBSP relative internal threshold (kept here since we don't keep an LBSP object)
const float m_fRelLBSPThreshold; const float m_fRelLBSPThreshold;
//! pre-allocated internal LBSP threshold values for all possible 8-bit intensity values //! pre-allocated internal LBSP threshold values for all possible 8-bit intensity values
size_t m_anLBSPThreshold_8bitLUT[UCHAR_MAX+1]; size_t m_anLBSPThreshold_8bitLUT[UCHAR_MAX + 1];
//! defines whether or not the subtractor is fully initialized //! defines whether or not the subtractor is fully initialized
bool m_bInitialized; bool m_bInitialized;
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment