Skip to content

Commit

Permalink
update decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
antinucleon committed Mar 17, 2015
1 parent e4491a4 commit 1b7411a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ else
CFLAGS+= -DCXXNET_USE_OPENCV=0
endif

ifeq ($(USE_OPENCV_DECODER),1)
CFLAGS+= -DCXXNET_USE_OPENCV_DECODER=1
else
CFLAGS+= -DCXXNET_USE_OPENCV_DECODER=0
endif

# customize cudnn path
ifneq ($(USE_CUDNN_PATH), NONE)
CFLAGS += -I$(USE_CUDNN_PATH)
Expand Down
4 changes: 2 additions & 2 deletions make/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ USE_CUDA_PATH = NONE
# you can disable it, however, you will not able to use
# imbin iterator
USE_OPENCV = 1

# whether use CUDNN R2 library
USE_OPENCV_DECODER = 1
# whether use CUDNN R3 library
USE_CUDNN = 0
# add the path to CUDNN libary to link and compile flag
# if you do not need that, or do not have that, leave it as NONE
Expand Down
6 changes: 1 addition & 5 deletions src/utils/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ struct JpegDecoder {
#if CXXNET_USE_OPENCV
struct OpenCVDecoder {
void Decode(unsigned char *ptr, size_t sz, mshadow::TensorContainer<cpu, 3, unsigned char> *p_data) {
// can be improved without memcpy buf
cv::Mat buf(0, 0, CV_8U);
buf.data = ptr;
buf.rows = 1;
buf.cols = sz;
cv::Mat buf(1, sz, CV_8U, ptr);
cv::Mat res = cv::imdecode(buf, 1);
utils::Assert(res.data != NULL, "decoding fail");
p_data->Resize(mshadow::Shape3(res.rows, res.cols, 3));
Expand Down

0 comments on commit 1b7411a

Please sign in to comment.