Skip to content
Snippets Groups Projects
Commit 7265a1a9 authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

changed tabs by spaces (werror misleading-identation)

parent 686f1995
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1060824152">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1060824152" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.base.1060824152" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cdt.managedbuild.toolchain.gnu.base.1060824152.880296614" name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.base.1480444461" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.GNU_ELF" id="cdt.managedbuild.target.gnu.platform.base.592180380" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
<builder buildPath="${workspace_loc:/vision_utils/build}" id="cdt.managedbuild.target.gnu.builder.base.567500383" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.target.gnu.builder.base"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.70783715" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.14005989" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option id="gnu.cpp.compiler.option.preprocessor.def.762213695" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="__cplusplus=201103=__cplusplus=201103"/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.1959754092" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/usr/include/eigen3"/>
<listOptionValue builtIn="false" value="/usr/local/include/opencv2"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1139568866" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1737626299" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<option id="gnu.c.compiler.option.preprocessor.def.symbols.2004195007" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="__cplusplus=201103=__cplusplus=201103"/>
</option>
<option id="gnu.c.compiler.option.include.paths.929409518" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/usr/include/eigen3"/>
<listOptionValue builtIn="false" value="/usr/local/include/opencv2"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.715196728" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.887355911" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.294869422" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1723926561" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.base.1006132387" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
<option id="gnu.both.asm.option.include.paths.198920140" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/usr/include/eigen3"/>
<listOptionValue builtIn="false" value="/usr/local/include/opencv2"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.126200658" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="vision_utils.null.1390279720" name="vision_utils"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/vision_utils"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1819918851;cdt.managedbuild.toolchain.gnu.base.1819918851.1318867162;cdt.managedbuild.tool.gnu.cpp.compiler.base.1649772065;cdt.managedbuild.tool.gnu.cpp.compiler.input.146329834">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.207681558;cdt.managedbuild.toolchain.gnu.base.207681558.1208625085;cdt.managedbuild.tool.gnu.c.compiler.base.1439246049;cdt.managedbuild.tool.gnu.c.compiler.input.637694474">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.727026548;cdt.managedbuild.toolchain.gnu.base.727026548.1071101131;cdt.managedbuild.tool.gnu.c.compiler.base.61708613;cdt.managedbuild.tool.gnu.c.compiler.input.166078074">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1060824152;cdt.managedbuild.toolchain.gnu.base.1060824152.880296614;cdt.managedbuild.tool.gnu.cpp.compiler.base.14005989;cdt.managedbuild.tool.gnu.cpp.compiler.input.1139568866">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.207681558;cdt.managedbuild.toolchain.gnu.base.207681558.1208625085;cdt.managedbuild.tool.gnu.cpp.compiler.base.1755527935;cdt.managedbuild.tool.gnu.cpp.compiler.input.1794914341">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.727026548;cdt.managedbuild.toolchain.gnu.base.727026548.1071101131;cdt.managedbuild.tool.gnu.cpp.compiler.base.433122623;cdt.managedbuild.tool.gnu.cpp.compiler.input.341288586">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.772018425;cdt.managedbuild.toolchain.gnu.cross.base.772018425.677700058;cdt.managedbuild.tool.gnu.cross.cpp.compiler.1552607345;cdt.managedbuild.tool.gnu.cpp.compiler.input.2062058076">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1819918851;cdt.managedbuild.toolchain.gnu.base.1819918851.1318867162;cdt.managedbuild.tool.gnu.c.compiler.base.593702953;cdt.managedbuild.tool.gnu.c.compiler.input.392834553">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1736073220;cdt.managedbuild.toolchain.gnu.base.1736073220.1390770886;cdt.managedbuild.tool.gnu.cpp.compiler.base.1526891046;cdt.managedbuild.tool.gnu.cpp.compiler.input.1116382079">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1736073220;cdt.managedbuild.toolchain.gnu.base.1736073220.1390770886;cdt.managedbuild.tool.gnu.c.compiler.base.1459107576;cdt.managedbuild.tool.gnu.c.compiler.input.1695301683">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1060824152;cdt.managedbuild.toolchain.gnu.base.1060824152.880296614;cdt.managedbuild.tool.gnu.c.compiler.base.1737626299;cdt.managedbuild.tool.gnu.c.compiler.input.715196728">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1244102678;cdt.managedbuild.toolchain.gnu.base.1244102678.1450977940;cdt.managedbuild.tool.gnu.cpp.compiler.base.1572359948;cdt.managedbuild.tool.gnu.cpp.compiler.input.466329004">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.772018425;cdt.managedbuild.toolchain.gnu.cross.base.772018425.677700058;cdt.managedbuild.tool.gnu.cross.c.compiler.2113617585;cdt.managedbuild.tool.gnu.c.compiler.input.844027082">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1244102678;cdt.managedbuild.toolchain.gnu.base.1244102678.1450977940;cdt.managedbuild.tool.gnu.c.compiler.base.1838202852;cdt.managedbuild.tool.gnu.c.compiler.input.964584931">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
</cproject>
......@@ -4,13 +4,13 @@ namespace vision_utils {
AlgorithmACTIVESEARCH::AlgorithmACTIVESEARCH(void)
{
initialized_=false;
initialized_=false;
}
AlgorithmACTIVESEARCH::~AlgorithmACTIVESEARCH(void)
{
if (params_ptr_->draw_results)
cv::destroyAllWindows();
cv::destroyAllWindows();
}
void AlgorithmACTIVESEARCH::initAlg(const int& _img_width, const int& _img_height, const int& _margin)
......@@ -20,12 +20,12 @@ void AlgorithmACTIVESEARCH::initAlg(const int& _img_width, const int& _img_heigh
margin_ = _margin;
if (img_size_(0) == 0 || img_size_(1) == 0)
std::cerr << "[Algorithm ACTIVESEARCH]: Image size not set. Current values [" << img_size_(0) << "x" << img_size_(1) << "]" << std::endl;
if (params_ptr_->n_cells_h == 0 || params_ptr_->n_cells_v == 0)
std::cerr << "[Algorithm ACTIVESEARCH]: number of cells not set. Current values [" << params_ptr_->n_cells_h << "," << params_ptr_->n_cells_v << "]" << std::endl;
if (img_size_(0) == 0 || img_size_(1) == 0)
std::cerr << "[Algorithm ACTIVESEARCH]: Image size not set. Current values [" << img_size_(0) << "x" << img_size_(1) << "]" << std::endl;
if (params_ptr_->n_cells_h == 0 || params_ptr_->n_cells_v == 0)
std::cerr << "[Algorithm ACTIVESEARCH]: number of cells not set. Current values [" << params_ptr_->n_cells_h << "," << params_ptr_->n_cells_v << "]" << std::endl;
// Set internal variables
// Set internal variables
projections_count_.resize(params_ptr_->n_cells_h + 1, params_ptr_->n_cells_v + 1);
empty_cells_tile_tmp_.resize(2, (params_ptr_->n_cells_h + 1) * (params_ptr_->n_cells_v + 1));
grid_size_(0) = params_ptr_->n_cells_h + 1;
......@@ -37,18 +37,18 @@ void AlgorithmACTIVESEARCH::initAlg(const int& _img_width, const int& _img_heigh
// set all ready to start clean
this->clear();
if (params_ptr_->draw_results)
{
cv::startWindowThread();
cv::namedWindow(getName(), cv::WINDOW_NORMAL);
}
if (params_ptr_->draw_results)
{
cv::startWindowThread();
cv::namedWindow(getName(), cv::WINDOW_NORMAL);
}
initialized_ = true;
}
void AlgorithmACTIVESEARCH::initAlg(const cv::Mat& _img, const int& _margin)
{
initAlg(_img.cols, _img.rows, _margin);
initAlg(_img.cols, _img.rows, _margin);
}
void AlgorithmACTIVESEARCH::resizeImage(void)
......@@ -60,7 +60,8 @@ void AlgorithmACTIVESEARCH::resizeImage(void)
}
// Functions to fill in cells
bool AlgorithmACTIVESEARCH::pickEmptyCell(Eigen::Vector2i & _cell) {
bool AlgorithmACTIVESEARCH::pickEmptyCell(Eigen::Vector2i & _cell)
{
int k = 0;
Eigen::Vector2i cell0;
for (int i = 1; i < grid_size_(0) - 1; i++) {
......@@ -131,63 +132,63 @@ void AlgorithmACTIVESEARCH::blockCell(const cv::Rect & _roi)
void AlgorithmACTIVESEARCH::run(Buffer<FramePtr>& _frame_buff, const DetectorBasePtr& _det_ptr, const DescriptorBasePtr& _des_ptr, const MatcherBasePtr& _mat_ptr)
{
// Initialize vars if necessary
if (!initialized_)
initAlg(_frame_buff.back()->getImage(), _det_ptr->getPatternRadius());
switch (_frame_buff.size())
{
case 0:
VU_ERROR("Trying to track an empty buffer. Please, at least insert one image in the buffer.");
break;
case 1:
detectNewFeatures(_frame_buff.back(), _det_ptr, _des_ptr, params_ptr_->max_new_features);
break;
default:
trackFrame(_frame_buff[_frame_buff.size()-2], _frame_buff.back(), _det_ptr, _des_ptr, _mat_ptr);
break;
}
// Initialize vars if necessary
if (!initialized_)
initAlg(_frame_buff.back()->getImage(), _det_ptr->getPatternRadius());
switch (_frame_buff.size())
{
case 0:
VU_ERROR("Trying to track an empty buffer. Please, at least insert one image in the buffer.");
break;
case 1:
detectNewFeatures(_frame_buff.back(), _det_ptr, _des_ptr, params_ptr_->max_new_features);
break;
default:
trackFrame(_frame_buff[_frame_buff.size()-2], _frame_buff.back(), _det_ptr, _des_ptr, _mat_ptr);
break;
}
}
void AlgorithmACTIVESEARCH::detectNewFeatures(FramePtr& _frame, const DetectorBasePtr& _det_ptr, const DescriptorBasePtr& _des_ptr, const int& max_new_features)
{
KeyPointVector kps;
cv::Mat desc;
cv::Rect roi;
KeyPointVector kps;
cv::Mat desc;
cv::Rect roi;
if (params_ptr_->draw_results)
image_draw_ = _frame->getImage().clone();
for (unsigned int n_iterations = 0; max_new_features == 0 || n_iterations < max_new_features; n_iterations++)
{
// Pick a ROI to look for a feature in it
if (pickEmptyRoi(roi))
{
// draw ROI
// if (params_ptr_->draw_results)
// drawRoi(image_draw_, roi, getName(), cv::Scalar(255,255,255));
// Detect features in ROI
kps = _det_ptr->detect(_frame->getImage(), roi);
desc = _des_ptr->getDescriptor(_frame->getImage(), kps);
if (kps.size() > 0)
{
// Keep best in cell
KeyPointVector list_keypoints = kps;
// cv::KeyPointsFilter keypoint_filter;
// keypoint_filter.retainBest(kps,1);
retainBest(kps,1);
// Check if point exist in list
int index = existsInKPVec(kps[0], list_keypoints, 1.0);
if(kps[0].response > params_ptr_->min_response_new_feature)
{
// Keep feature
_frame->addKeyPoint(kps[0]);
_frame->addDescriptor(desc.row(index));
image_draw_ = _frame->getImage().clone();
for (unsigned int n_iterations = 0; max_new_features == 0 || n_iterations < max_new_features; n_iterations++)
{
// Pick a ROI to look for a feature in it
if (pickEmptyRoi(roi))
{
// draw ROI
// if (params_ptr_->draw_results)
// drawRoi(image_draw_, roi, getName(), cv::Scalar(255,255,255));
// Detect features in ROI
kps = _det_ptr->detect(_frame->getImage(), roi);
desc = _des_ptr->getDescriptor(_frame->getImage(), kps);
if (kps.size() > 0)
{
// Keep best in cell
KeyPointVector list_keypoints = kps;
// cv::KeyPointsFilter keypoint_filter;
// keypoint_filter.retainBest(kps,1);
retainBest(kps,1);
// Check if point exist in list
int index = existsInKPVec(kps[0], list_keypoints, 1.0);
if(kps[0].response > params_ptr_->min_response_new_feature)
{
// Keep feature
_frame->addKeyPoint(kps[0]);
_frame->addDescriptor(desc.row(index));
// Hit cell
hitCell(kps[0]);
......@@ -195,64 +196,64 @@ void AlgorithmACTIVESEARCH::detectNewFeatures(FramePtr& _frame, const DetectorBa
// Debug
if (params_ptr_->draw_results)
{
drawRoi(image_draw_, roi, getName(), cv::Scalar(50,255,0), 1, 0.1);
cv::circle(image_draw_, kps[0].pt, 5, cv::Scalar(255, 0, 100), -1, 8, 0);
drawRoi(image_draw_, roi, getName(), cv::Scalar(50,255,0), 1, 0.1);
cv::circle(image_draw_, kps[0].pt, 5, cv::Scalar(255, 0, 100), -1, 8, 0);
}
}
}
else
{
// Block cell
blockCell(roi);
// Debug
}
}
else
{
// Block cell
blockCell(roi);
// Debug
if (params_ptr_->draw_results)
drawRoi(image_draw_, roi, getName(), cv::Scalar(255,0,0), 1, 0.1);
}
}
drawRoi(image_draw_, roi, getName(), cv::Scalar(255,0,0), 1, 0.1);
}
}
else
break;
}
}
if (params_ptr_->draw_results)
{
cv::imshow(getName(), image_draw_);
cv::waitKey(1);
cv::imshow(getName(), image_draw_);
cv::waitKey(1);
}
}
void AlgorithmACTIVESEARCH::trackFrame(const FramePtr& _frame_old, FramePtr& _tracked_frame, const DetectorBasePtr& _det_ptr, const DescriptorBasePtr& _des_ptr, const MatcherBasePtr& _mat_ptr)
{
// Start timer
clock_t tStart = clock();
// Start timer
clock_t tStart = clock();
if (params_ptr_->draw_results)
image_draw_ = _tracked_frame->getImage().clone();
image_draw_ = _tracked_frame->getImage().clone();
// Renew active ROI
renew();
// Renew active ROI
renew();
KeyPointVector target_feature = _frame_old->getKeyPoints();
cv::Mat target_desc = _frame_old->getDescriptors();
KeyPointVector target_feature = _frame_old->getKeyPoints();
cv::Mat target_desc = _frame_old->getDescriptors();
// Try to track all previous features
for(int ii=0; ii<target_feature.size(); ++ii)
// Try to track all previous features
for(int ii=0; ii<target_feature.size(); ++ii)
{
// Hit cell in the position of the targeted kp
hitCell(target_feature[ii]);
// Hit cell in the position of the targeted kp
hitCell(target_feature[ii]);
// Set ROI
cv::Rect roi = setRoi(target_feature[ii].pt.x,target_feature[ii].pt.y, cell_size_(0), cell_size_(1));
// Set ROI
cv::Rect roi = setRoi(target_feature[ii].pt.x,target_feature[ii].pt.y, cell_size_(0), cell_size_(1));
// // draw ROI
// if (params_ptr_->draw_results)
// drawRoi(image_draw_, roi, getName(), cv::Scalar(0,255,255));
// // draw ROI
// if (params_ptr_->draw_results)
// drawRoi(image_draw_, roi, getName(), cv::Scalar(0,255,255));
// Detect features in ROI
KeyPointVector kps = _det_ptr->detect(_tracked_frame->getImage(), roi);
cv::Mat desc = _des_ptr->getDescriptor(_tracked_frame->getImage(), kps);
KeyPointVector kps = _det_ptr->detect(_tracked_frame->getImage(), roi);
cv::Mat desc = _des_ptr->getDescriptor(_tracked_frame->getImage(), kps);
// If there are keypoints around the candidate ROI
// If there are keypoints around the candidate ROI
if(kps.size() > 0)
{
// Match
......@@ -262,8 +263,8 @@ void AlgorithmACTIVESEARCH::trackFrame(const FramePtr& _frame_old, FramePtr& _tr
// If good match, keep feature
if (normalized_score > _mat_ptr->getParams()->min_norm_score)
{
// introduce in list of tracked features
cv::KeyPoint tracked_kp = kps[match_data.trainIdx];
// introduce in list of tracked features
cv::KeyPoint tracked_kp = kps[match_data.trainIdx];
cv::Mat tracked_desc = desc(cv::Rect(0,match_data.trainIdx,desc.cols,1));
_tracked_frame->addKeyPoint(tracked_kp);
_tracked_frame->addDescriptor(tracked_desc);
......@@ -271,28 +272,28 @@ void AlgorithmACTIVESEARCH::trackFrame(const FramePtr& _frame_old, FramePtr& _tr
// Draw
if (params_ptr_->draw_results)
{
cv::line(image_draw_, tracked_kp.pt, target_feature[ii].pt, cv::Scalar(0, 0, 255), 3);
cv::circle(image_draw_, tracked_kp.pt, 5, cv::Scalar(255.0, 255.0, 0.0), -1, 8, 0);
cv::putText(image_draw_, std::to_string(ii), tracked_kp.pt, cv:: FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(0, 0, 0));
cv::line(image_draw_, tracked_kp.pt, target_feature[ii].pt, cv::Scalar(0, 0, 255), 3);
cv::circle(image_draw_, tracked_kp.pt, 5, cv::Scalar(255.0, 255.0, 0.0), -1, 8, 0);
cv::putText(image_draw_, std::to_string(ii), tracked_kp.pt, cv:: FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(0, 0, 0));
}
}
}
}
// If not enough tracked features, add new ones
if (_tracked_frame->getNumFeatures() < params_ptr_->min_feat_track)
detectNewFeatures(_tracked_frame, _det_ptr, _des_ptr, params_ptr_->max_new_features - _tracked_frame->getNumFeatures());
else
{
if (params_ptr_->draw_results)
{
cv::imshow(getName(), image_draw_);
cv::waitKey(1);
}
}
// Get computation time
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
// If not enough tracked features, add new ones
if (_tracked_frame->getNumFeatures() < params_ptr_->min_feat_track)
detectNewFeatures(_tracked_frame, _det_ptr, _des_ptr, params_ptr_->max_new_features - _tracked_frame->getNumFeatures());
else
{
if (params_ptr_->draw_results)
{
cv::imshow(getName(), image_draw_);
cv::waitKey(1);
}
}
// Get computation time
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
}
......
......@@ -197,17 +197,20 @@ vector<cv::KeyPoint> RangeTree(vector<cv::KeyPoint> keyPoints, int numRetPoints,
result.push_back(i);
int minx = keyPoints[i].pt.x-width; int maxx = keyPoints[i].pt.x+width; //defining square boundaries around the point
int miny= keyPoints[i].pt.y-width; int maxy= keyPoints[i].pt.y+width;
if (minx<0) minx = 0; if (miny<0) miny = 0;
if (minx<0) minx = 0;
if (miny<0) miny = 0;
std::vector<u16 *> *he = treeANMS.search(minx, maxx, miny, maxy);
for (unsigned int j=0; j<he->size();j++) if (Included[(u64) (*he)[j]]) Included[(u64) (*he)[j]] = false;
for (unsigned int j=0; j<he->size();j++)
if (Included[(u64) (*he)[j]])
Included[(u64) (*he)[j]] = false;
delete he;
he = NULL;
}
}
if (result.size()>=Kmin && result.size()<=Kmax){ //solution found
ResultVec = result;
complete = true;
ResultVec = result;
complete = true;
}
else if (result.size()<Kmin) high = width-1; //update binary search range
else low = width+1;
......@@ -215,7 +218,8 @@ vector<cv::KeyPoint> RangeTree(vector<cv::KeyPoint> keyPoints, int numRetPoints,
}
// retrieve final keypoints
vector<cv::KeyPoint> kp;
for (unsigned int i = 0; i<ResultVec.size(); i++) kp.push_back(keyPoints[ResultVec[i]]);
for (unsigned int i = 0; i<ResultVec.size(); i++)
kp.push_back(keyPoints[ResultVec[i]]);
return kp;
}
......@@ -260,7 +264,7 @@ vector<int> Ssc(const vector<cv::KeyPoint>& keyPoints, const int& numRetPoints,
for (unsigned int i=0;i<keyPoints.size();++i){
int row = floor(keyPoints[i].pt.y/c); //get position of the cell current point is located at
int row = floor(keyPoints[i].pt.y/c); //get position of the cell current point is located at
int col = floor(keyPoints[i].pt.x/c);
if (coveredVec[row][col]==false){ // if the cell is not covered
result.push_back(i);
......@@ -316,7 +320,6 @@ void Ssc(const vector<cv::KeyPoint>& keyPoints, vector<cv::KeyPoint>& keyPointsS
}
}
void VisualizeAll(cv::Mat Image, vector<cv::KeyPoint> keyPoints, string figureTitle)
{
cv::Mat resultImg;
......
......@@ -7,49 +7,49 @@ namespace vision_utils {
AlgorithmOPTFLOWPYRLK::AlgorithmOPTFLOWPYRLK(void)
{
initialized_ = false;
initialized_ = false;
}
AlgorithmOPTFLOWPYRLK::~AlgorithmOPTFLOWPYRLK(void)
{
if (params_ptr_->draw_results)
cv::destroyAllWindows();
cv::destroyAllWindows();
}
void AlgorithmOPTFLOWPYRLK::initAlg(void)
{
if (params_ptr_->draw_results)
{
cv::startWindowThread();
cv::namedWindow(getName(), cv::WINDOW_NORMAL);
}
if (params_ptr_->draw_results)
{
cv::startWindowThread();
cv::namedWindow(getName(), cv::WINDOW_NORMAL);
}
initialized_ = true;
}
void AlgorithmOPTFLOWPYRLK::run(Buffer<FramePtr>& _frame_buff, const DetectorBasePtr& _det_ptr)
{
// Initialize vars if necessary
if (!initialized_)
initAlg();
switch (_frame_buff.size())
{
case 0:
VU_ERROR("Trying to track an empty buffer. Please, at least insert one image in the buffer.");
break;
case 1:
detectNewFeatures(_frame_buff.back(), _det_ptr);
break;
default:
trackFrame(_frame_buff[_frame_buff.size()-2], _frame_buff.back(), _det_ptr);
break;
}
// Initialize vars if necessary
if (!initialized_)
initAlg();
switch (_frame_buff.size())
{
case 0:
VU_ERROR("Trying to track an empty buffer. Please, at least insert one image in the buffer.");
break;
case 1:
detectNewFeatures(_frame_buff.back(), _det_ptr);
break;
default:
trackFrame(_frame_buff[_frame_buff.size()-2], _frame_buff.back(), _det_ptr);
break;
}
}
void AlgorithmOPTFLOWPYRLK::detectNewFeatures(FramePtr& _frame, const DetectorBasePtr& _det_ptr)
{
if (params_ptr_->draw_results)
image_draw_ = _frame->getImage().clone();
image_draw_ = _frame->getImage().clone();
// Convert to gray scale if necessary
cv::Mat img_gray;
......@@ -58,44 +58,44 @@ void AlgorithmOPTFLOWPYRLK::detectNewFeatures(FramePtr& _frame, const DetectorBa
else
img_gray = _frame->getImage().clone();
KeyPointVector kps_new;
cv::Mat desc_new;
if (_frame->getNumFeatures() > 0)
{
// Get features again
KeyPointVector kps = _det_ptr->detect(img_gray);
// Keep only new features
KeyPointVector tracked_kps = _frame->getKeyPoints();
std::vector<int> kps_idxs;
kps_new = differenceKPVec(tracked_kps, kps, kps_idxs);
}
else
{
// Get full frame detections
kps_new = _det_ptr->detect(img_gray);
}
_frame->setKeyPoints(kps_new);
KeyPointVector kps_new;
cv::Mat desc_new;
if (_frame->getNumFeatures() > 0)
{
// Get features again
KeyPointVector kps = _det_ptr->detect(img_gray);
// Keep only new features
KeyPointVector tracked_kps = _frame->getKeyPoints();
std::vector<int> kps_idxs;
kps_new = differenceKPVec(tracked_kps, kps, kps_idxs);
}
else
{
// Get full frame detections
kps_new = _det_ptr->detect(img_gray);
}
_frame->setKeyPoints(kps_new);
if (params_ptr_->draw_results)
{
drawKeyPoints(image_draw_, kps_new, 5, cv::Scalar(255,0,100), -1);
cv::imshow(getName(), image_draw_);
cv::waitKey(1);
drawKeyPoints(image_draw_, kps_new, 5, cv::Scalar(255,0,100), -1);
cv::imshow(getName(), image_draw_);
cv::waitKey(1);
}
frame_gray_prev_ = img_gray.clone();
}
void AlgorithmOPTFLOWPYRLK::trackFrame(const FramePtr& _frame_old, FramePtr& _tracked_frame, const DetectorBasePtr& _det_ptr)
{
// Start timer
clock_t tStart = clock();
// Start timer
clock_t tStart = clock();
if (params_ptr_->draw_results)
image_draw_ = _tracked_frame->getImage().clone();
image_draw_ = _tracked_frame->getImage().clone();
// Convert to gray scale if necessary
// Convert to gray scale if necessary
cv::Mat img_gray;
if (_tracked_frame->getImage().channels() == 3)
cv::cvtColor(_tracked_frame->getImage(), img_gray, CV_RGB2GRAY);
......@@ -109,41 +109,41 @@ void AlgorithmOPTFLOWPYRLK::trackFrame(const FramePtr& _frame_old, FramePtr& _tr
// Compute optical flow
if (pts_prev.size() > 0)
cv::calcOpticalFlowPyrLK(frame_gray_prev_, img_gray, pts_prev, pts_matched_in_frame, kpt_is_found, err, params_ptr_->win_size, params_ptr_->max_level, params_ptr_->criteria, params_ptr_->flags, params_ptr_->min_eig_threshold);
cv::calcOpticalFlowPyrLK(frame_gray_prev_, img_gray, pts_prev, pts_matched_in_frame, kpt_is_found, err, params_ptr_->win_size, params_ptr_->max_level, params_ptr_->criteria, params_ptr_->flags, params_ptr_->min_eig_threshold);
//Draw lines connecting previous position and current position
KeyPointVector good_kpts;
for(size_t ii=0; ii<pts_matched_in_frame.size(); ii++)
{
if(kpt_is_found[ii] && err[ii] < params_ptr_->min_err_kpt_match)
{
cv::KeyPoint kp(pts_matched_in_frame[ii], CV_32F);
good_kpts.push_back(kp);
cv::circle(image_draw_, pts_matched_in_frame[ii], 5, cv::Scalar(255.0, 255.0, 0.0), -1);
cv::line(image_draw_, pts_prev[ii], pts_matched_in_frame[ii], cv::Scalar(0, 0, 255), 3);
cv::putText(image_draw_, std::to_string(ii), pts_matched_in_frame[ii], cv:: FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(0, 0, 0));
}
if(kpt_is_found[ii] && err[ii] < params_ptr_->min_err_kpt_match)
{
cv::KeyPoint kp(pts_matched_in_frame[ii], CV_32F);
good_kpts.push_back(kp);
cv::circle(image_draw_, pts_matched_in_frame[ii], 5, cv::Scalar(255.0, 255.0, 0.0), -1);
cv::line(image_draw_, pts_prev[ii], pts_matched_in_frame[ii], cv::Scalar(0, 0, 255), 3);
cv::putText(image_draw_, std::to_string(ii), pts_matched_in_frame[ii], cv:: FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(0, 0, 0));
}
}
// Update
_tracked_frame->setKeyPoints(good_kpts);
// If not enough tracked features, add new ones
// If not enough tracked features, add new ones
if (_tracked_frame->getNumFeatures() < params_ptr_->min_feat_track)
detectNewFeatures(_tracked_frame, _det_ptr);
detectNewFeatures(_tracked_frame, _det_ptr);
else
{
// Draw
if (params_ptr_->draw_results)
{
cv::imshow(getName(), image_draw_);
cv::waitKey(1);
}
// Draw
if (params_ptr_->draw_results)
{
cv::imshow(getName(), image_draw_);
cv::waitKey(1);
}
}
frame_gray_prev_ = img_gray.clone();
frame_gray_prev_ = img_gray.clone();
// Get computation time
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
// Get computation time
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
}
} /* namespace vision_utils */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment