SOMHunter Core
sh::Somhunter Class Reference

The main C++ API of the SOMHunter Core. More...

#include <somhunter.h>

Collaboration diagram for sh::Somhunter:

Public Member Functions

 Somhunter ()=delete
 
 Somhunter (const std::string &config_filepath)
 The main ctor with the config from the JSON config file. More...
 
GetDisplayResult get_display (DisplayType d_type, FrameId selected_image=0, PageId page=0, bool log_it=true)
 Returns display of the desired type. More...
 
std::vector< bool > like_frames (const std::vector< FrameId > &new_likes)
 Inverts the like states of the provided frames and returns the new states. More...
 
std::vector< bool > bookmark_frames (const std::vector< FrameId > &new_bookmarks)
 (De)selects the provided frames from the bookmark list. More...
 
std::vector< const Keyword * > autocomplete_keywords (const std::string &prefix, size_t count=5) const
 Returns the nearest supported keyword matches to the provided prefix. More...
 
RescoreResult rescore (Query &query, bool benchmark_run=false)
 Applies all algorithms for score computation and updates context. More...
 
const UserContextswitch_search_context (size_t index, size_t src_search_ctx_ID=SIZE_T_ERR_VAL, const std::string &screenshot_fpth="", const std::string &label="")
 Switches the search context for the user to the provided index in the history and returns reference to it. More...
 
const SearchContextget_search_context () const
 Returns a reference to the current user's search context. More...
 
const UserContextget_user_context () const
 Returns a reference to the current user's context. More...
 
const VideoFrameget_frame (FrameId ID) const
 
FrameRange get_frames (VideoId video_ID, FrameNum fr, FrameNum to) const
 
VideoFramePointer get_frame_ptr (FrameId img) const
 
bool som_ready () const
 Returns true if the user's SOM is ready. More...
 
bool som_ready (size_t temp_id) const
 
void reset_search_session ()
 Resets current search context and starts new search. More...
 
bool login_to_eval_server ()
 Tries to login into the remote evaluation server (competition one). More...
 
bool logout_from_eval_server ()
 Tries to logout from the remote evaluation server (competition one). More...
 
SubmitResult submit_to_eval_server (FrameId frame_id)
 Sumbits frame with given id to VBS server. More...
 
void log_video_replay (FrameId frame_ID, float delta_X)
 
void log_scroll (DisplayType t, float delta_Y)
 
void log_text_query_change (const std::string &text_query)
 
void log_canvas_query_change ()
 
std::string store_rescore_screenshot (const std::string &filepath)
 
size_t get_num_frames () const
 
const std::vector< FrameId > & get_top_scored (size_t max_count=0, size_t from_video=0, size_t from_shot=0) const
 
std::vector< VideoFramePointerget_top_scored_frames (size_t max_count=0, size_t from_video=0, size_t from_shot=0) const
 
std::vector< float > get_top_scored_scores (std::vector< FrameId > &top_scored_frames) const
 
size_t find_targets (const std::vector< FrameId > &top_scored, const std::vector< FrameId > &targets) const
 
const Settingssettings () const
 
const std::string & get_config_filepath ()
 
const std::string & get_API_config_filepath ()
 
const KeywordRankertextual_model ()
 
void benchmark_native_text_queries (const std::string &queries_filepath, const std::string &out_dir)
 
void benchmark_canvas_queries (const std::string &queries_dir, const std::string &out_dir)
 
void benchmark_real_queries (const std::string &queries_dir, const std::string &targets_fpth, const std::string &out_dir)
 
void generate_example_images_for_keywords ()
 Generates the top example images from the database for all supported W2VV keywords. More...
 
void run_basic_test ()
 
void run_generators ()
 

Static Public Member Functions

static void write_resultset (const std::string &file, const std::vector< VideoFramePointer > &results)
 
static void write_query (const std::string &file, const Query &q)
 
static void write_query_info (const std::string &file, const std::string &ID, const std::string &user, const std::tuple< VideoId, FrameId, FrameId > &target, std::size_t pos_vid, std::size_t pos_fr, std::size_t unpos_vid, std::size_t unpos_fr)
 

Private Member Functions

void apply_filters ()
 
void generate_new_targets ()
 Generates the new debug targets. More...
 
template<typename SpecificKWRanker , typename SpecificFrameFeatures >
void rescore_keywords (SpecificKWRanker &kw_ranker, const TextualQuery &query, size_t temporal, const SpecificFrameFeatures &features)
 Applies text query from the user. More...
 
void rescore_feedback ()
 Applies the relevance feedback from the user based on images the user already saw (as implicit negative examples). More...
 
void som_start (size_t temporal)
 Gives the SOM worker the new work. More...
 
FramePointerRange get_random_display ()
 
FramePointerRange get_topn_display (PageId page)
 
FramePointerRange get_topn_context_display (PageId page)
 
FramePointerRange get_som_display ()
 
FramePointerRange get_som_relocation_display (size_t temp_id)
 
FramePointerRange get_video_detail_display (FrameId selected_image, bool log_it=true)
 
FramePointerRange get_topKNN_display (FrameId selected_image, PageId page)
 
FramePointerRange get_page_from_last (PageId page)
 
void reset_scores (float val=1.0F)
 
void push_search_ctx ()
 Adds the currently active search context to the history and starts a new context (with next contiguous ID number) More...
 
bool has_metadata () const
 Returns true if LSC metadata file provided inside the config. More...
 

Private Attributes

const Settings _settings
 Current application settings. More...
 
const DatasetFrames _dataset_frames
 
const DatasetFeatures _dataset_features
 
UserContext _user_context
 
const std::string _core_settings_filepath
 
const std::string _API_settings_filepath
 
KeywordRanker _keyword_ranker
 
KeywordClipRanker _secondary_keyword_ranker
 
CanvasQueryRanker _collage_ranker
 
const RelocationRanker _relocation_ranker
 

Detailed Description

The main C++ API of the SOMHunter Core.

Every comunication from the outside world goes through this API. This API can be called directly from other C++ code or can be called by the HTTP API provided inside class NetworkApi.

Constructor & Destructor Documentation

◆ Somhunter() [1/2]

sh::Somhunter::Somhunter ( )
delete

◆ Somhunter() [2/2]

Somhunter::Somhunter ( const std::string &  config_filepath)

The main ctor with the config from the JSON config file.

Here is the call graph for this function:

Member Function Documentation

◆ apply_filters()

void Somhunter::apply_filters ( )
private
Here is the call graph for this function:

◆ autocomplete_keywords()

std::vector< const Keyword * > Somhunter::autocomplete_keywords ( const std::string &  prefix,
size_t  count = 5 
) const

Returns the nearest supported keyword matches to the provided prefix.

Here is the call graph for this function:

◆ benchmark_canvas_queries()

void Somhunter::benchmark_canvas_queries ( const std::string &  queries_dir,
const std::string &  out_dir 
)
Here is the call graph for this function:

◆ benchmark_native_text_queries()

void Somhunter::benchmark_native_text_queries ( const std::string &  queries_filepath,
const std::string &  out_dir 
)
Here is the call graph for this function:

◆ benchmark_real_queries()

void Somhunter::benchmark_real_queries ( const std::string &  queries_dir,
const std::string &  targets_fpth,
const std::string &  out_dir 
)
Here is the call graph for this function:

◆ bookmark_frames()

std::vector< bool > Somhunter::bookmark_frames ( const std::vector< FrameId > &  new_bookmarks)

(De)selects the provided frames from the bookmark list.

Here is the call graph for this function:

◆ find_targets()

size_t sh::Somhunter::find_targets ( const std::vector< FrameId > &  top_scored,
const std::vector< FrameId > &  targets 
) const

◆ generate_example_images_for_keywords()

void Somhunter::generate_example_images_for_keywords ( )

Generates the top example images from the database for all supported W2VV keywords.

For examples used as keyword-to-ID.W2VV-BoW.csv file.

Here is the call graph for this function:

◆ generate_new_targets()

void Somhunter::generate_new_targets ( )
private

Generates the new debug targets.

Here is the call graph for this function:

◆ get_API_config_filepath()

const std::string& sh::Somhunter::get_API_config_filepath ( )
inline

◆ get_config_filepath()

const std::string& sh::Somhunter::get_config_filepath ( )
inline

◆ get_display()

GetDisplayResult Somhunter::get_display ( DisplayType  d_type,
FrameId  selected_image = 0,
PageId  page = 0,
bool  log_it = true 
)

Returns display of the desired type.

Some diplays may even support paging (e.g. DISP_TOP_N) or selection of one frame (e.g. DISP_KNN).

Here is the call graph for this function:

◆ get_frame()

const VideoFrame & Somhunter::get_frame ( FrameId  ID) const
Here is the call graph for this function:

◆ get_frame_ptr()

VideoFramePointer Somhunter::get_frame_ptr ( FrameId  img) const
Here is the call graph for this function:

◆ get_frames()

FrameRange Somhunter::get_frames ( VideoId  video_ID,
FrameNum  fr,
FrameNum  to 
) const
Here is the call graph for this function:

◆ get_num_frames()

size_t sh::Somhunter::get_num_frames ( ) const
inline
Here is the call graph for this function:

◆ get_page_from_last()

FramePointerRange Somhunter::get_page_from_last ( PageId  page)
private
Here is the call graph for this function:

◆ get_random_display()

FramePointerRange Somhunter::get_random_display ( )
private
Here is the call graph for this function:

◆ get_search_context()

const SearchContext & Somhunter::get_search_context ( ) const

Returns a reference to the current user's search context.

◆ get_som_display()

FramePointerRange Somhunter::get_som_display ( )
private
Here is the call graph for this function:

◆ get_som_relocation_display()

FramePointerRange Somhunter::get_som_relocation_display ( size_t  temp_id)
private
Here is the call graph for this function:

◆ get_top_scored()

const std::vector< FrameId > & Somhunter::get_top_scored ( size_t  max_count = 0,
size_t  from_video = 0,
size_t  from_shot = 0 
) const
Here is the call graph for this function:

◆ get_top_scored_frames()

std::vector< VideoFramePointer > Somhunter::get_top_scored_frames ( size_t  max_count = 0,
size_t  from_video = 0,
size_t  from_shot = 0 
) const
Here is the call graph for this function:

◆ get_top_scored_scores()

std::vector< float > Somhunter::get_top_scored_scores ( std::vector< FrameId > &  top_scored_frames) const

◆ get_topKNN_display()

FramePointerRange Somhunter::get_topKNN_display ( FrameId  selected_image,
PageId  page 
)
private
Here is the call graph for this function:

◆ get_topn_context_display()

FramePointerRange Somhunter::get_topn_context_display ( PageId  page)
private
Here is the call graph for this function:

◆ get_topn_display()

FramePointerRange Somhunter::get_topn_display ( PageId  page)
private
Here is the call graph for this function:

◆ get_user_context()

const UserContext & Somhunter::get_user_context ( ) const

Returns a reference to the current user's context.

◆ get_video_detail_display()

FramePointerRange Somhunter::get_video_detail_display ( FrameId  selected_image,
bool  log_it = true 
)
private
Here is the call graph for this function:

◆ has_metadata()

bool Somhunter::has_metadata ( ) const
private

Returns true if LSC metadata file provided inside the config.

◆ like_frames()

std::vector< bool > Somhunter::like_frames ( const std::vector< FrameId > &  new_likes)

Inverts the like states of the provided frames and returns the new states.

Here is the call graph for this function:

◆ log_canvas_query_change()

void Somhunter::log_canvas_query_change ( )
Here is the call graph for this function:

◆ log_scroll()

void Somhunter::log_scroll ( DisplayType  t,
float  delta_Y 
)
Here is the call graph for this function:

◆ log_text_query_change()

void Somhunter::log_text_query_change ( const std::string &  text_query)
Here is the call graph for this function:

◆ log_video_replay()

void Somhunter::log_video_replay ( FrameId  frame_ID,
float  delta_X 
)
Here is the call graph for this function:

◆ login_to_eval_server()

bool Somhunter::login_to_eval_server ( )

Tries to login into the remote evaluation server (competition one).

Here is the call graph for this function:

◆ logout_from_eval_server()

bool Somhunter::logout_from_eval_server ( )

Tries to logout from the remote evaluation server (competition one).

Here is the call graph for this function:

◆ push_search_ctx()

void Somhunter::push_search_ctx ( )
private

Adds the currently active search context to the history and starts a new context (with next contiguous ID number)

◆ rescore()

RescoreResult Somhunter::rescore ( Query query,
bool  benchmark_run = false 
)

Applies all algorithms for score computation and updates context.

Returns references to existing history states that we can go back to (including the current one).

Here is the call graph for this function:

◆ rescore_feedback()

void Somhunter::rescore_feedback ( )
private

Applies the relevance feedback from the user based on images the user already saw (as implicit negative examples).

Here is the call graph for this function:

◆ rescore_keywords()

template<typename SpecificKWRanker , typename SpecificFrameFeatures >
void sh::Somhunter::rescore_keywords ( SpecificKWRanker &  kw_ranker,
const TextualQuery query,
size_t  temporal,
const SpecificFrameFeatures &  features 
)
private

Applies text query from the user.

◆ reset_scores()

void Somhunter::reset_scores ( float  val = 1.0F)
private
Here is the call graph for this function:

◆ reset_search_session()

void Somhunter::reset_search_session ( )

Resets current search context and starts new search.

Here is the call graph for this function:

◆ run_basic_test()

void Somhunter::run_basic_test ( )
Here is the call graph for this function:

◆ run_generators()

void Somhunter::run_generators ( )

◆ settings()

const Settings& sh::Somhunter::settings ( ) const
inline

◆ som_ready() [1/2]

bool Somhunter::som_ready ( ) const

Returns true if the user's SOM is ready.

Here is the call graph for this function:

◆ som_ready() [2/2]

bool Somhunter::som_ready ( size_t  temp_id) const

◆ som_start()

void Somhunter::som_start ( size_t  temporal)
private

Gives the SOM worker the new work.

Here is the call graph for this function:

◆ store_rescore_screenshot()

std::string Somhunter::store_rescore_screenshot ( const std::string &  filepath)

◆ submit_to_eval_server()

SubmitResult Somhunter::submit_to_eval_server ( FrameId  frame_id)

Sumbits frame with given id to VBS server.

Here is the call graph for this function:

◆ switch_search_context()

const UserContext & Somhunter::switch_search_context ( size_t  index,
size_t  src_search_ctx_ID = SIZE_T_ERR_VAL,
const std::string &  screenshot_fpth = "",
const std::string &  label = "" 
)

Switches the search context for the user to the provided index in the history and returns reference to it.

Here is the call graph for this function:

◆ textual_model()

const KeywordRanker* sh::Somhunter::textual_model ( )
inline

◆ write_query()

void Somhunter::write_query ( const std::string &  file,
const Query q 
)
static
Here is the call graph for this function:

◆ write_query_info()

void Somhunter::write_query_info ( const std::string &  file,
const std::string &  ID,
const std::string &  user,
const std::tuple< VideoId, FrameId, FrameId > &  target,
std::size_t  pos_vid,
std::size_t  pos_fr,
std::size_t  unpos_vid,
std::size_t  unpos_fr 
)
static

◆ write_resultset()

void Somhunter::write_resultset ( const std::string &  file,
const std::vector< VideoFramePointer > &  results 
)
static

Member Data Documentation

◆ _API_settings_filepath

const std::string sh::Somhunter::_API_settings_filepath
private

◆ _collage_ranker

CanvasQueryRanker sh::Somhunter::_collage_ranker
private

◆ _core_settings_filepath

const std::string sh::Somhunter::_core_settings_filepath
private

◆ _dataset_features

const DatasetFeatures sh::Somhunter::_dataset_features
private

◆ _dataset_frames

const DatasetFrames sh::Somhunter::_dataset_frames
private

◆ _keyword_ranker

KeywordRanker sh::Somhunter::_keyword_ranker
private

◆ _relocation_ranker

const RelocationRanker sh::Somhunter::_relocation_ranker
private

◆ _secondary_keyword_ranker

KeywordClipRanker sh::Somhunter::_secondary_keyword_ranker
private

◆ _settings

const Settings sh::Somhunter::_settings
private

Current application settings.

◆ _user_context

UserContext sh::Somhunter::_user_context
private

The documentation for this class was generated from the following files: