Skip to content

Commit 77530ea

Browse files
authored
Merge pull request #3 from kipr/refactor
Update Refactor branch
2 parents 2bb3e7f + 3c879c2 commit 77530ea

File tree

16 files changed

+156
-90
lines changed

16 files changed

+156
-90
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build
2-
.vscode/
2+
.vscode/
3+
documentation/html
4+
documentation/man

documentation/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ if (with_documentation)
2323
endforeach()
2424
list(APPEND DOCUMENTATION_DIRECTORIES ${CMAKE_SOURCE_DIR}/documentation/pages)
2525

26+
#Project Settings
27+
set(DOXYGEN_PROJECT_LOGO ${CMAKE_SOURCE_DIR}/documentation/kipr.png)
28+
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/documentation)
29+
#Build Settings
30+
set(DOXYGEN_EXTRACT_ALL YES)
31+
set(DOXYGEN_GENERATE_TODOLIST NO)
32+
#Input Settings
33+
set(DOXYGEN_RECURSIVE YES)
34+
#Source Browser Settings
35+
set(DOXYGEN_REFERENCED_BY_RELATION YES)
36+
set(DOXYGEN_REFERENCES_RELATION YES)
37+
#HTML
38+
#Note: Finding a red color that wasn't ugly was a challenge, so it's purple for now
39+
#(because purple is an awesome color)
40+
set(DOXYGEN_HTML_COLORSTYLE_HUE 243)
41+
set(DOXYGEN_HTML_COLORSTYLE_SAT 96)
42+
set(DOXYGEN_HTML_COLORSTYLE_GAMMA 95)
43+
set(DOXYGEN_DISABLE_INDEX YES)
44+
set(DOXYGEN_GENERATE_TREEVIEW YES)
45+
2646
doxygen_add_docs(
2747
documentation
2848
${DOCUMENTATION_DIRECTORIES}

documentation/kipr.png

11.2 KB
Loading

module/camera/dependencies/zlib/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ set(ZLIB_COMMON_OPTIONS
1111
if (CMAKE_CROSSCOMPILING)
1212
get_property(ARCH GLOBAL PROPERTY arch)
1313
ExternalProject_Add(dep_zlib
14-
URL https://www.zlib.net/zlib-1.2.12.tar.gz
14+
URL https://www.zlib.net/zlib-1.2.13.tar.gz
1515
CMAKE_ARGS
1616
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
1717
${ZLIB_COMMON_OPTIONS}
1818
INSTALL_COMMAND make install
1919
)
2020
else()
2121
ExternalProject_Add(dep_zlib
22-
URL https://www.zlib.net/zlib-1.2.12.tar.gz
22+
URL https://www.zlib.net/zlib-1.2.13.tar.gz
2323
CMAKE_ARGS
2424
${ZLIB_COMMON_OPTIONS}
2525
INSTALL_COMMAND make install
@@ -36,4 +36,4 @@ target_include_directories(zlib_wrapper INTERFACE ${ZLIB_INCLUDE_DIR})
3636
# z
3737
add_library(z_wrapper INTERFACE)
3838
add_dependencies(z_wrapper zlib_wrapper)
39-
target_link_libraries(z_wrapper INTERFACE zlib_wrapper z)
39+
target_link_libraries(z_wrapper INTERFACE zlib_wrapper z)

module/camera/protected/kipr/camera/channel.hpp renamed to module/camera/protected/kipr/camera/channel_impl.hpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#ifndef _KIPR_CAMERA_CHANNEL_HPP_
2-
#define _KIPR_CAMERA_CHANNEL_HPP_
1+
#ifndef _KIPR_CAMERA_CHANNEL_IMPL_HPP_
2+
#define _KIPR_CAMERA_CHANNEL_IMPL_HPP_
33

44
#include "kipr/camera/object.hpp"
55
#include "kipr/config/config.hpp"
6+
#include "kipr/camera/channel.hpp"
67

78
#include <opencv2/core/core.hpp>
89

@@ -41,29 +42,6 @@ namespace kipr
4142
static std::map<std::string, ChannelImpl *> m_channelImpls;
4243
};
4344

44-
class Channel
45-
{
46-
public:
47-
Channel(Device *device, const config::Config &config);
48-
~Channel();
49-
50-
void invalidate();
51-
const ObjectVector *objects() const;
52-
Device *device() const;
53-
54-
/**
55-
* Do not call this method unless you know what you are doing!
56-
*/
57-
void setConfig(const config::Config &config);
58-
59-
private:
60-
Device *m_device;
61-
config::Config m_config;
62-
mutable ObjectVector m_objects;
63-
ChannelImpl *m_impl;
64-
mutable bool m_valid;
65-
};
66-
6745
typedef std::vector<Channel *> ChannelPtrVector;
6846
}
6947
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef _KIPR_CAMERA_CHANNEL_HPP_
2+
#define _KIPR_CAMERA_CHANNEL_HPP_
3+
4+
#include "kipr/camera/object.hpp"
5+
#include "kipr/config/config.hpp"
6+
7+
namespace kipr
8+
{
9+
namespace camera
10+
{
11+
class Device;
12+
class ChannelImpl;
13+
14+
class Channel
15+
{
16+
public:
17+
Channel(Device *device, const config::Config &config);
18+
~Channel();
19+
20+
void invalidate();
21+
const ObjectVector *objects() const;
22+
Device *device() const;
23+
24+
/**
25+
* Do not call this method unless you know what you are doing!
26+
*/
27+
void setConfig(const config::Config &config);
28+
29+
private:
30+
Device *m_device;
31+
config::Config m_config;
32+
mutable ObjectVector m_objects;
33+
ChannelImpl *m_impl;
34+
mutable bool m_valid;
35+
};
36+
}
37+
}
38+
39+
#endif

module/camera/public/kipr/camera/image.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _KIPR_CAMERA_IMAGE_HPP_
22
#define _KIPR_CAMERA_IMAGE_HPP_
33

4+
#include <algorithm>
5+
46
namespace kipr
57
{
68
namespace camera
@@ -29,6 +31,8 @@ namespace kipr
2931
Image(const Image &);
3032
Image(Image &&);
3133

34+
Image &operator=(Image);
35+
3236
~Image();
3337

3438
bool isEmpty() const;
@@ -41,6 +45,17 @@ namespace kipr
4145
unsigned getStride() const;
4246
bool isOwned() const;
4347

48+
friend void swap(Image &first, Image &second)
49+
{
50+
using std::swap;
51+
swap(first.type_, second.type_);
52+
swap(first.data_, second.data_);
53+
swap(first.owned_, second.owned_);
54+
swap(first.width_, second.width_);
55+
swap(first.height_, second.height_);
56+
swap(first.stride_, second.stride_);
57+
}
58+
4459
private:
4560
Type type_;
4661
unsigned char *data_;

module/camera/src/camera.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "channel_p.hpp"
33
#include "kipr/camera/camera.h"
44
#include "kipr/camera/channel.hpp"
5+
#include "kipr/camera/channel_impl.hpp"
56
#include "UDPVideo.hpp"
67

78
#include <csetjmp>

module/camera/src/camera_c.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "kipr/camera/camera.h"
22
#include "kipr/camera/camera.hpp"
33
#include "kipr/camera/channel.hpp"
4+
#include "kipr/camera/channel_impl.hpp"
45
#include "kipr/log/log.hpp"
56
#include "camera_c_p.hpp"
67
#include "logger.hpp"

module/camera/src/channel.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,6 @@
66
using namespace kipr;
77
using namespace kipr::camera;
88

9-
ChannelImpl::ChannelImpl() : m_dirty(true) {}
10-
11-
ChannelImpl::~ChannelImpl() {}
12-
13-
void ChannelImpl::setImage(const cv::Mat &image)
14-
{
15-
if (image.empty())
16-
{
17-
m_image = cv::Mat();
18-
m_dirty = true;
19-
return;
20-
}
21-
m_image = image;
22-
m_dirty = true;
23-
}
24-
25-
ObjectVector ChannelImpl::objects(const config::Config &config)
26-
{
27-
if (m_dirty)
28-
{
29-
update(m_image);
30-
m_dirty = false;
31-
}
32-
return findObjects(config);
33-
}
34-
35-
std::map<std::string, ChannelImpl *> ChannelImplManager::m_channelImpls = {
36-
{"hsv", new HsvChannelImpl()},
37-
};
38-
39-
void ChannelImplManager::setImage(const cv::Mat &image)
40-
{
41-
std::map<std::string, ChannelImpl *>::iterator it = m_channelImpls.begin();
42-
for (; it != m_channelImpls.end(); ++it)
43-
it->second->setImage(image);
44-
}
45-
46-
ChannelImpl *ChannelImplManager::channelImpl(const std::string &name)
47-
{
48-
std::map<std::string, ChannelImpl *>::iterator it = m_channelImpls.find(name);
49-
return (it == m_channelImpls.end()) ? 0 : it->second;
50-
}
51-
52-
// Channel //
53-
549
Channel::Channel(Device *device, const config::Config &config)
5510
: m_device(device), m_config(config), m_impl(0), m_valid(false)
5611
{

module/camera/src/channel_impl.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include "kipr/camera/channel_impl.hpp"
2+
#include "channel_p.hpp"
3+
4+
#include "logger.hpp"
5+
6+
using namespace kipr;
7+
using namespace kipr::camera;
8+
9+
ChannelImpl::ChannelImpl() : m_dirty(true) {}
10+
11+
ChannelImpl::~ChannelImpl() {}
12+
13+
void ChannelImpl::setImage(const cv::Mat &image)
14+
{
15+
if (image.empty())
16+
{
17+
m_image = cv::Mat();
18+
m_dirty = true;
19+
return;
20+
}
21+
m_image = image;
22+
m_dirty = true;
23+
}
24+
25+
ObjectVector ChannelImpl::objects(const config::Config &config)
26+
{
27+
if (m_dirty)
28+
{
29+
update(m_image);
30+
m_dirty = false;
31+
}
32+
return findObjects(config);
33+
}
34+
35+
std::map<std::string, ChannelImpl *> ChannelImplManager::m_channelImpls = {
36+
{"hsv", new HsvChannelImpl()},
37+
};
38+
39+
void ChannelImplManager::setImage(const cv::Mat &image)
40+
{
41+
std::map<std::string, ChannelImpl *>::iterator it = m_channelImpls.begin();
42+
for (; it != m_channelImpls.end(); ++it)
43+
it->second->setImage(image);
44+
}
45+
46+
ChannelImpl *ChannelImplManager::channelImpl(const std::string &name)
47+
{
48+
std::map<std::string, ChannelImpl *>::iterator it = m_channelImpls.find(name);
49+
return (it == m_channelImpls.end()) ? 0 : it->second;
50+
}

module/camera/src/channel_p.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _KIPR_CAMERA_CHANNEL_P_HPP_
33

44
#include "kipr/camera/camera.hpp"
5-
#include "kipr/camera/channel.hpp"
5+
#include "kipr/camera/channel_impl.hpp"
66
#include "kipr/camera/object.hpp"
77
#include <opencv2/core/core.hpp>
88

module/camera/src/image.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Image::Image(
2121
unsigned char *const data,
2222
const bool owned
2323
) : type_(type)
24-
, data_(nullptr)
24+
, data_(data)
2525
, owned_(owned)
2626
, width_(width)
2727
, height_(height)
@@ -53,6 +53,12 @@ Image::Image(Image &&rhs)
5353
rhs.owned_ = false;
5454
}
5555

56+
Image &Image::operator=(Image other)
57+
{
58+
swap(*this, other);
59+
return *this;
60+
}
61+
5662
Image::~Image()
5763
{
5864
if (owned_) delete[] data_;

module/core/src/device/wombat/wombat_device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class WombatDevice : public kipr::core::Device
162162
return false;
163163
}
164164

165-
if (read_buffer[0] != 'J')
165+
if (read_buffer && read_buffer[0] != 'J')
166166
{
167167
logger.error() << "DMA de-synchronized";
168168
return false;

0 commit comments

Comments
 (0)