-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from kipr/refactor
Update Refactor branch
- Loading branch information
Showing
16 changed files
with
156 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
build | ||
.vscode/ | ||
.vscode/ | ||
documentation/html | ||
documentation/man |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef _KIPR_CAMERA_CHANNEL_HPP_ | ||
#define _KIPR_CAMERA_CHANNEL_HPP_ | ||
|
||
#include "kipr/camera/object.hpp" | ||
#include "kipr/config/config.hpp" | ||
|
||
namespace kipr | ||
{ | ||
namespace camera | ||
{ | ||
class Device; | ||
class ChannelImpl; | ||
|
||
class Channel | ||
{ | ||
public: | ||
Channel(Device *device, const config::Config &config); | ||
~Channel(); | ||
|
||
void invalidate(); | ||
const ObjectVector *objects() const; | ||
Device *device() const; | ||
|
||
/** | ||
* Do not call this method unless you know what you are doing! | ||
*/ | ||
void setConfig(const config::Config &config); | ||
|
||
private: | ||
Device *m_device; | ||
config::Config m_config; | ||
mutable ObjectVector m_objects; | ||
ChannelImpl *m_impl; | ||
mutable bool m_valid; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "kipr/camera/channel_impl.hpp" | ||
#include "channel_p.hpp" | ||
|
||
#include "logger.hpp" | ||
|
||
using namespace kipr; | ||
using namespace kipr::camera; | ||
|
||
ChannelImpl::ChannelImpl() : m_dirty(true) {} | ||
|
||
ChannelImpl::~ChannelImpl() {} | ||
|
||
void ChannelImpl::setImage(const cv::Mat &image) | ||
{ | ||
if (image.empty()) | ||
{ | ||
m_image = cv::Mat(); | ||
m_dirty = true; | ||
return; | ||
} | ||
m_image = image; | ||
m_dirty = true; | ||
} | ||
|
||
ObjectVector ChannelImpl::objects(const config::Config &config) | ||
{ | ||
if (m_dirty) | ||
{ | ||
update(m_image); | ||
m_dirty = false; | ||
} | ||
return findObjects(config); | ||
} | ||
|
||
std::map<std::string, ChannelImpl *> ChannelImplManager::m_channelImpls = { | ||
{"hsv", new HsvChannelImpl()}, | ||
}; | ||
|
||
void ChannelImplManager::setImage(const cv::Mat &image) | ||
{ | ||
std::map<std::string, ChannelImpl *>::iterator it = m_channelImpls.begin(); | ||
for (; it != m_channelImpls.end(); ++it) | ||
it->second->setImage(image); | ||
} | ||
|
||
ChannelImpl *ChannelImplManager::channelImpl(const std::string &name) | ||
{ | ||
std::map<std::string, ChannelImpl *>::iterator it = m_channelImpls.find(name); | ||
return (it == m_channelImpls.end()) ? 0 : it->second; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.