Skip to content

Commit

Permalink
mods-with-mask expects B&W masks with image img1_mask.png, where img1…
Browse files Browse the repository at this point in the history
… is *.jpg file specified in console input
  • Loading branch information
ducha-aiki committed Aug 8, 2018
1 parent 5a9818c commit 8d9df27
Show file tree
Hide file tree
Showing 4 changed files with 550 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ TARGET_LINK_LIBRARIES(synth-detection matching mser affinedetectors helpers ${Op
add_executable(mods mods.cpp correspondencebank.cpp imagerepresentation.cpp io_mods.cpp)
TARGET_LINK_LIBRARIES(mods inih matching synth-detection mser affinedetectors ${OpenCV_LIBS} zmq)

add_executable(mods-with-mask mods-with-mask.cpp correspondencebank.cpp imagerepresentation.cpp io_mods.cpp)
TARGET_LINK_LIBRARIES(mods-with-mask inih matching synth-detection mser affinedetectors ${OpenCV_LIBS} zmq)


add_executable(extract_features extract_features.cpp correspondencebank.cpp imagerepresentation.cpp io_mods.cpp)
TARGET_LINK_LIBRARIES(extract_features inih matching synth-detection mser affinedetectors ${OpenCV_LIBS} zmq)

Expand Down
12 changes: 11 additions & 1 deletion imagerepresentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,17 @@ void ImageRepresentation::SynthDetectDescribeKeypoints (IterationViewsynthesisPa
}
ReprojectRegions(temp_kp1_desc, temp_img1.H, OriginalImg.cols, OriginalImg.rows);
}

if (mask.cols == OriginalImg.cols) {
std::cout << "Mask filtering" << std::endl;
AffineRegionVector temp_kp1_filtered;
for (int kp_id = 0; kp_id < temp_kp1_desc.size(); kp_id++){
if (mask.at<unsigned char>(int(temp_kp1_desc[kp_id].reproj_kp.y),int(temp_kp1_desc[kp_id].reproj_kp.x)) > 0) {
temp_kp1_filtered.push_back(temp_kp1_desc[kp_id]);
}
}
std::cout << temp_kp1_filtered.size() << " out of " << temp_kp1_desc.size() << " left" << std::endl;
temp_kp1_desc = temp_kp1_filtered;
}
///Description
///
time1 = ((double) (getMilliSecs1() - s_time)) / 1000;
Expand Down
1 change: 1 addition & 0 deletions imagerepresentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ImageRepresentation
DominantOrientationParams &dom_ori_par, double* H,
const int width2, const int height2);
cv::Mat OriginalImg;
cv::Mat mask;
void SaveRegions(std::string fname, int mode);
void SaveRegionsAMatrix(std::string fname);
void SaveRegionsMichal(std::string fname, int mode);
Expand Down
Loading

0 comments on commit 8d9df27

Please sign in to comment.