ObjectLocalizerProcessorJob.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package VisionX::Component
19  * @author Kai Welke (welke at kit dot edu)
20  * @date 2013
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 #include <VisionX/interface/components/ObjectLocalizerInterfaces.h>
28 
29 #include <atomic>
30 #include <mutex>
31 
32 namespace visionx
33 {
34  class ObjectLocalizerProcessor;
35 
36  /**
37  * ObjectLocalizerProcessorJob encapsules the object localization job.
38  * This helper class is used internally by ObjectLocalizerProcessor
39  * in order to assure execution of all relevant interface methods in
40  * a single thread (as e.g. required for methods using OpenGL as
41  * SegmentableObjectRecognition)
42  */
44  {
45  public:
46  /**
47  * Init the job by providing the ObjectLocalizerProcessor that implements the required functionality.
48  *
49  * @param processor pointer to the processor. Called by ObjectLocalizerProcessor.
50  */
52 
53  /**
54  * Processing method. Schedules initialization of the recognizer, object database and localization
55  * requests in a single thread. Called by ObjectLocalizerProcessor.
56  */
57  void process();
58 
59  /**
60  * Requests exit to the job. Assures the process method retruns as soon as possible. Non-blocking and
61  * called by ObjectLocalizerProcessor.
62  */
63  void exit();
64 
65  /**
66  * Start a localization job for the given objectClassName
67  *
68  * @param objectClassName name of the object class to localize
69  */
70  void start(std::vector<std::string> objectClassNames);
71  void reset();
72 
73  /**
74  * Wait for the localization result. Will return an empty result on exit
75  *
76  * @return Localization result list
77  */
78  memoryx::ObjectLocalizationResultList waitForResult();
79 
80 
81  private:
82  ObjectLocalizerProcessor* processor;
83 
84  std::vector<std::string> objectClassNames;
85  memoryx::ObjectLocalizationResultList result;
86 
87  std::mutex jobMutex;
88  std::atomic<bool> jobPending;
89  std::atomic<bool> jobFinished;
90  std::atomic<bool> abortRequested;
91  };
92 }
93 
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ObjectLocalizerProcessorJob::exit
void exit()
Requests exit to the job.
Definition: ObjectLocalizerProcessorJob.cpp:67
visionx::ObjectLocalizerProcessorJob::waitForResult
memoryx::ObjectLocalizationResultList waitForResult()
Wait for the localization result.
Definition: ObjectLocalizerProcessorJob.cpp:56
visionx::ObjectLocalizerProcessorJob::reset
void reset()
Definition: ObjectLocalizerProcessorJob.cpp:51
visionx::ObjectLocalizerProcessorJob
ObjectLocalizerProcessorJob encapsules the object localization job.
Definition: ObjectLocalizerProcessorJob.h:43
visionx::ObjectLocalizerProcessorJob::start
void start(std::vector< std::string > objectClassNames)
Start a localization job for the given objectClassName.
Definition: ObjectLocalizerProcessorJob.cpp:42
visionx::ObjectLocalizerProcessorJob::ObjectLocalizerProcessorJob
ObjectLocalizerProcessorJob(ObjectLocalizerProcessor *processor)
Init the job by providing the ObjectLocalizerProcessor that implements the required functionality.
Definition: ObjectLocalizerProcessorJob.cpp:34
visionx::ObjectLocalizerProcessorJob::process
void process()
Processing method.
Definition: ObjectLocalizerProcessorJob.cpp:72
visionx::ObjectLocalizerProcessor
ObjectLocalizerProcessor.
Definition: ObjectLocalizerProcessor.h:107