vocabtree  0.0.1
matches_page.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utils/dataset.hpp>
4 #include <string>
5 
6 /// MatchesPage class keeps track of query images and their matches, and outputs an html
7 /// page containing these matches for visualization purposes.
8 class MatchesPage {
9 public:
10  /// Ctor, max_matches_per_page specified the max number of rows per page, if this is set too
11  /// high, the web browser might have problems loading the page. max_images_per_match specifies
12  /// the max number of images in each row. If this is set too high, the web browser might have
13  /// problems loading the page.
14  MatchesPage(uint32_t max_matches_per_page = 16, uint32_t max_images_per_match = 16);
15  ~MatchesPage();
16 
17  /// Adds a match to the html_strings variable which will be written as html on write().
18  /// The query_id is the id of the image query. match_ids are the ids of the matches.
19  /// Finally, dataset is used to figure out the image paths. If validated vector is provided,
20  /// the web page will highlight validated matches, values should be zero if unvalidated,
21  /// > 0 if validated, and < 0 if failed validation. The validation vector can be smaller
22  /// than the size of match_ids, in which case it is assumed to correspond to beginning of
23  /// match_ids.
24  void add_match(uint32_t query_id, std::vector<uint64_t> &match_ids, const Dataset &dataset,
25  std::shared_ptr< std::vector<int> > validated = nullptr);
26 
27  /// Writes out all the html match mages to the input specified folder. The first page
28  /// will look something like folder/matches_00000.html.
29  void write(const std::string &folder) const;
30 
31 protected:
32 
33  std::string stylesheet() const; /// Returns a string containing css stylesheet
34  std::string header() const; /// Returns a string containing the html header
35  std::string footer() const; /// Returns a string containing the html footer
36  std::string navbar(uint32_t cur_page, uint32_t max_pages) const; /// Returns a string containing the navbar needed for pagination
37  std::string pagename(uint32_t cur_page) const; /// Returns a string containing the pagename (ex. matches_00001.html)
38 
39  std::vector<std::string> html_strings; /// Holds the html strings for each match passed into add_match
40 
42 
43 };