Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
fe073d1f
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fe073d1f
编写于
11月 30, 2016
作者:
D
dangqingqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add style check and remove 'using namespace'
上级
4d997823
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
24 addition
and
18 deletion
+24
-18
CMakeLists.txt
CMakeLists.txt
+1
-0
plugin/opencv/CMakeLists.txt
plugin/opencv/CMakeLists.txt
+3
-0
plugin/opencv/DataTransformer.cpp
plugin/opencv/DataTransformer.cpp
+6
-4
plugin/opencv/DataTransformer.h
plugin/opencv/DataTransformer.h
+10
-9
plugin/opencv/PyDecodejpeg.cpp
plugin/opencv/PyDecodejpeg.cpp
+4
-5
未找到文件。
CMakeLists.txt
浏览文件 @
fe073d1f
...
...
@@ -43,6 +43,7 @@ option(WITH_SWIG_PY "Compile PaddlePaddle with py PaddlePaddle prediction api" $
option
(
ON_TRAVIS
"Running test on travis-ci or not."
OFF
)
option
(
ON_COVERALLS
"Generating code coverage data on coveralls or not."
OFF
)
option
(
COVERALLS_UPLOAD
"Uploading the generated coveralls json."
ON
)
option
(
USE_OPENCV
"Compile PaddlePaddle with opencv"
OFF
)
if
(
NOT CMAKE_BUILD_TYPE
)
set
(
CMAKE_BUILD_TYPE
"RelWithDebInfo"
CACHE STRING
...
...
plugin/opencv/CMakeLists.txt
浏览文件 @
fe073d1f
...
...
@@ -42,3 +42,6 @@ add_library(DeJpeg SHARED ${DEJPEG_SOURCES})
target_compile_options
(
DeJpeg BEFORE PRIVATE
${
BUILD_PRIVATE_FLAGS
}
)
target_link_libraries
(
DeJpeg
${
DEJPEG_LINKER_LIBS
}
)
set_target_properties
(
DeJpeg PROPERTIES PREFIX
""
)
add_style_check_target
(
DeJpeg
${
DEJPEG_SOURCES
}
)
add_style_check_target
(
DeJpeg
${
DEJPEG_HEADER
}
)
plugin/opencv/DataTransformer.cpp
浏览文件 @
fe073d1f
...
...
@@ -51,7 +51,7 @@ DataTransformer::DataTransformer(int threadNum,
}
numThreads_
=
threadNum
;
syncThreadPool_
.
reset
(
new
SyncThreadPool
(
numThreads_
,
false
));
syncThreadPool_
.
reset
(
new
paddle
::
SyncThreadPool
(
numThreads_
,
false
));
}
void
DataTransformer
::
loadMean
(
float
*
values
)
{
...
...
@@ -66,7 +66,7 @@ void DataTransformer::loadMean(float* values) {
void
DataTransformer
::
startFetching
(
const
char
*
src
,
const
int
size
,
float
*
trg
)
{
vector
<
char
>
imbuf
(
src
,
src
+
size
);
std
::
vector
<
char
>
imbuf
(
src
,
src
+
size
);
int
cvFlag
=
(
isColor_
?
CV_LOAD_IMAGE_COLOR
:
CV_LOAD_IMAGE_GRAYSCALE
);
cv
::
Mat
im
=
cv
::
imdecode
(
cv
::
Mat
(
imbuf
),
cvFlag
);
if
(
!
im
.
data
)
{
...
...
@@ -83,7 +83,7 @@ int DataTransformer::Rand(int min, int max) {
return
dist
(
rng
);
}
void
DataTransformer
::
transform
(
Mat
&
cvImgOri
,
float
*
target
)
{
void
DataTransformer
::
transform
(
cv
::
Mat
&
cvImgOri
,
float
*
target
)
{
const
int
imgChannels
=
cvImgOri
.
channels
();
const
int
imgHeight
=
cvImgOri
.
rows
;
const
int
imgWidth
=
cvImgOri
.
cols
;
...
...
@@ -152,7 +152,9 @@ void DataTransformer::transform(Mat& cvImgOri, float* target) {
}
// target: BGR
}
void
DataTransformer
::
start
(
vector
<
char
*>&
data
,
int
*
datalen
,
int
*
labels
)
{
void
DataTransformer
::
start
(
std
::
vector
<
char
*>&
data
,
int
*
datalen
,
int
*
labels
)
{
auto
job
=
[
&
](
int
tid
,
int
numThreads
)
{
for
(
size_t
i
=
tid
;
i
<
data
.
size
();
i
+=
numThreads
)
{
DataTypePtr
ret
=
prefetchFree_
.
dequeue
();
...
...
plugin/opencv/DataTransformer.h
浏览文件 @
fe073d1f
...
...
@@ -12,6 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifndef DATATRANSFORMER_H_
#define DATATRANSFORMER_H_
#include <iostream>
#include <fstream>
#include <opencv2/opencv.hpp>
...
...
@@ -21,9 +24,6 @@ limitations under the License. */
#include "paddle/utils/Thread.h"
using
namespace
cv
;
using
namespace
paddle
;
/**
* This is an image processing module with OpenCV, such as
* resizing, scaling, mirroring, substracting the image mean...
...
...
@@ -57,7 +57,7 @@ public:
* @param data Data containing the image string to be transformed.
* @param label The label of input image.
*/
void
start
(
vector
<
char
*>&
data
,
int
*
datalen
,
int
*
labels
);
void
start
(
std
::
vector
<
char
*>&
data
,
int
*
datalen
,
int
*
labels
);
/**
* @brief Applies the transformation on one image Mat.
...
...
@@ -65,7 +65,7 @@ public:
* @param img The input img to be transformed.
* @param target target is used to save the transformed data.
*/
void
transform
(
Mat
&
img
,
float
*
target
);
void
transform
(
cv
::
Mat
&
img
,
float
*
target
);
/**
* @brief Decode the image string, then calls transform() function.
...
...
@@ -114,8 +114,9 @@ private:
typedef
std
::
pair
<
float
*
,
int
>
DataType
;
typedef
std
::
shared_ptr
<
DataType
>
DataTypePtr
;
std
::
vector
<
DataTypePtr
>
prefetch_
;
std
::
unique_ptr
<
SyncThreadPool
>
syncThreadPool_
;
BlockingQueue
<
DataTypePtr
>
prefetchFree_
;
BlockingQueue
<
DataTypePtr
>
prefetchFull_
;
std
::
unique_ptr
<
paddle
::
SyncThreadPool
>
syncThreadPool_
;
paddle
::
BlockingQueue
<
DataTypePtr
>
prefetchFree_
;
paddle
::
BlockingQueue
<
DataTypePtr
>
prefetchFull_
;
};
// class DataTransformer
#endif // DATATRANSFORMER_H_
plugin/opencv/PyDecodejpeg.cpp
浏览文件 @
fe073d1f
...
...
@@ -23,8 +23,6 @@ limitations under the License. */
#include "DataTransformer.h"
using
namespace
boost
::
python
;
/**
* DecodeJpeg is an image processing API for interfacing Python and C++
* code DataTransformer, which used OpenCV and multi-threads to accelerate
...
...
@@ -83,7 +81,7 @@ public:
* It's type is numpy.array with int32.
*/
void
start
(
boost
::
python
::
list
&
pysrc
,
PyObject
*
pydlen
,
PyObject
*
pylabel
)
{
vector
<
char
*>
data
;
std
::
vector
<
char
*>
data
;
int
num
=
len
(
pysrc
);
for
(
int
t
=
0
;
t
<
num
;
++
t
)
{
char
*
src
=
boost
::
python
::
extract
<
char
*>
(
pysrc
[
t
]);
...
...
@@ -169,8 +167,9 @@ static void initPython() {
*/
BOOST_PYTHON_MODULE
(
DeJpeg
)
{
initPython
();
class_
<
DecodeJpeg
>
(
"DecodeJpeg"
,
init
<
int
,
int
,
bool
,
bool
,
int
,
int
,
int
,
PyObject
*>
())
boost
::
python
::
class_
<
DecodeJpeg
>
(
"DecodeJpeg"
,
boost
::
python
::
init
<
int
,
int
,
bool
,
bool
,
int
,
int
,
int
,
PyObject
*>
())
.
def
(
"start"
,
&
DecodeJpeg
::
start
)
.
def
(
"get"
,
&
DecodeJpeg
::
get
);
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录