Skip to content

Commit aee06e9

Browse files
committed
opt code
1 parent 7a5368e commit aee06e9

File tree

5 files changed

+3
-65
lines changed

5 files changed

+3
-65
lines changed

infinite_sense_core/include/image.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,6 @@ struct GMatType {
7272
enum { Type = ((GElement<EleType>::Type & 0x7) + ((channelSize - 1) << 3)) };
7373
};
7474

75-
struct UMatData // for OpenCV Version 3
76-
{
77-
enum {
78-
COPY_ON_MAP = 1,
79-
HOST_COPY_OBSOLETE = 2,
80-
DEVICE_COPY_OBSOLETE = 4,
81-
TEMP_UMAT = 8,
82-
TEMP_COPIED_UMAT = 24,
83-
USER_ALLOCATED = 32,
84-
DEVICE_MEM_MAPPED = 64
85-
};
86-
const void* prev_allocator;
87-
const void* curr_allocator;
88-
int ref_count;
89-
int refcount;
90-
uchar* data;
91-
uchar* orig_data;
92-
size_t size;
93-
94-
int flags;
95-
void* handle;
96-
void* userdata;
97-
int allocator_flags;
98-
int map_count;
99-
UMatData* original_u_mat_data;
100-
};
101-
10275
class GMat {
10376
public:
10477
GMat();
@@ -150,7 +123,6 @@ class GMat {
150123
static void* FastMalloc(size_t size, int image_align = 16);
151124
static void FastFree(void* ptr);
152125
static size_t AlignSize(size_t sz, int n);
153-
static void Deallocate(UMatData* u);
154126

155127
public:
156128
int cols, rows, flags;

infinite_sense_core/src/image.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,6 @@ void GMat::Release() {
8181
FastFree(data);
8282
ref_count = nullptr;
8383
data = nullptr;
84-
} else // OpenCV3 style
85-
{
86-
if (auto* u = reinterpret_cast<UMatData*>(reinterpret_cast<uchar*>(ref_count) - offsetof(UMatData, refcount));
87-
u->userdata == data + align_bytes) {
88-
// this is allocated by GMat, we need minus both refcount
89-
ref_count = static_cast<int*>(u->userdata);
90-
if (CvXAdd(ref_count, -1) == 1) {
91-
return Release();
92-
}
93-
} else {
94-
assert(u->size == total_bytes);
95-
Deallocate(u);
96-
}
97-
cols = rows = 0;
98-
ref_count = nullptr;
99-
data = nullptr;
10084
}
10185
}
10286

@@ -134,22 +118,4 @@ size_t GMat::AlignSize(const size_t sz, const int n) {
134118
assert((n & (n - 1)) == 0); // n is a power of 2
135119
return (sz + n - 1) & -n;
136120
}
137-
138-
void GMat::Deallocate(UMatData* u) // for OpenCV Version 3
139-
{
140-
if (!u) {
141-
return;
142-
}
143-
assert(u->ref_count == 0);
144-
assert(u->refcount == 0);
145-
if (!(u->flags & UMatData::USER_ALLOCATED)) {
146-
const uchar* udata = reinterpret_cast<uchar**>(u->orig_data)[-1];
147-
if (const int n = u->orig_data - udata; (n & (n - 1)) == 0 && n >= 0 && n <= 32) {
148-
FastFree(u->orig_data);
149-
} else
150-
free(u->orig_data);
151-
u->orig_data = nullptr;
152-
}
153-
delete u;
154-
}
155121
} // namespace infinite_sense

infinite_sense_core/src/messenger.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Messenger::Messenger() {
1111
subscriber_ = zmq::socket_t(context_, zmq::socket_type::sub);
1212
publisher_.bind(endpoint_);
1313
subscriber_.connect(endpoint_);
14-
1514
LOG(INFO) << "Link Net: " << endpoint_;
1615
} catch (const zmq::error_t& e) {
1716
LOG(ERROR) << "Net initialization error: " << e.what();

infinite_sense_core/src/net.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
namespace infinite_sense {
77

8-
NetManager::NetManager(std::string target_ip, unsigned short port) : port_(port), target_ip_(std::move(target_ip)) {
8+
NetManager::NetManager(std::string target_ip, const unsigned short port)
9+
: port_(port), target_ip_(std::move(target_ip)) {
910
net_ptr_ = std::make_shared<UDPSocket>();
1011
const uint64_t curr_time = static_cast<uint64_t>(
1112
std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now().time_since_epoch())

infinite_sense_core/src/usb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace infinite_sense {
77

8-
UsbManager::UsbManager(std::string port, const int baud_rate) : port_(std::move(port)), started_(false) {
8+
UsbManager::UsbManager(std::string port, const int baud_rate) : port_(std::move(port)) {
99
serial_ptr_ = std::make_unique<serial::Serial>();
1010
try {
1111
serial_ptr_->setPort(port_);

0 commit comments

Comments
 (0)