Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
879c0196
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
879c0196
编写于
2月 13, 2014
作者:
I
Ilya Lavrenov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enabled OpenGL on MacOSX
上级
e5567907
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
53 addition
and
47 deletion
+53
-47
CMakeLists.txt
CMakeLists.txt
+1
-1
modules/core/src/gl_core_3_1.cpp
modules/core/src/gl_core_3_1.cpp
+18
-13
samples/cpp/Qt_sample/CMakeLists.txt
samples/cpp/Qt_sample/CMakeLists.txt
+1
-1
samples/cpp/Qt_sample/qt_opengl.cpp
samples/cpp/Qt_sample/qt_opengl.cpp
+33
-32
未找到文件。
CMakeLists.txt
浏览文件 @
879c0196
...
...
@@ -142,7 +142,7 @@ OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF
OCV_OPTION
(
WITH_JASPER
"Include JPEG2K support"
ON
IF
(
NOT IOS
)
)
OCV_OPTION
(
WITH_JPEG
"Include JPEG support"
ON
)
OCV_OPTION
(
WITH_OPENEXR
"Include ILM support via OpenEXR"
ON
IF
(
NOT IOS
)
)
OCV_OPTION
(
WITH_OPENGL
"Include OpenGL support"
OFF
IF
(
NOT ANDROID
AND NOT APPLE
)
)
OCV_OPTION
(
WITH_OPENGL
"Include OpenGL support"
OFF
IF
(
NOT ANDROID
)
)
OCV_OPTION
(
WITH_OPENNI
"Include OpenNI support"
OFF
IF
(
NOT ANDROID AND NOT IOS
)
)
OCV_OPTION
(
WITH_PNG
"Include PNG support"
ON
)
OCV_OPTION
(
WITH_PVAPI
"Include Prosilica GigE support"
ON
IF
(
NOT ANDROID AND NOT IOS
)
)
...
...
modules/core/src/gl_core_3_1.cpp
浏览文件 @
879c0196
...
...
@@ -47,22 +47,27 @@
#include "gl_core_3_1.hpp"
#ifdef HAVE_OPENGL
#if defined(__APPLE__)
#include <mach-o/dyld.h>
#ifdef __APPLE__
#include <dlfcn.h>
static
void
*
AppleGLGetProcAddress
(
const
char
*
name
)
{
static
const
struct
mach_header
*
image
=
0
;
if
(
!
image
)
image
=
NSAddImage
(
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
,
NSADDIMAGE_OPTION_RETURN_ON_ERROR
);
// prepend a '_' for the Unix C symbol mangling convention
std
::
string
symbolName
=
"_"
;
symbolName
+=
std
::
string
(
name
);
NSSymbol
symbol
=
image
?
NSLookupSymbolInImage
(
image
,
&
symbolName
[
0
],
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
|
NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
)
:
0
;
return
symbol
?
NSAddressOfSymbol
(
symbol
)
:
0
;
static
bool
initialized
=
false
;
static
void
*
handle
=
NULL
;
if
(
!
handle
)
{
if
(
!
initialized
)
{
initialized
=
true
;
const
char
*
const
path
=
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
;
handle
=
dlopen
(
path
,
RTLD_LAZY
|
RTLD_GLOBAL
);
}
if
(
!
handle
)
return
NULL
;
}
return
dlsym
(
handle
,
name
);
}
#endif // __APPLE__
...
...
samples/cpp/Qt_sample/CMakeLists.txt
浏览文件 @
879c0196
...
...
@@ -7,6 +7,6 @@ FIND_PACKAGE( OpenCV REQUIRED )
find_package
(
OpenGL REQUIRED
)
ADD_EXECUTABLE
(
OpenGL_Qt_Binding
main
.cpp
)
ADD_EXECUTABLE
(
OpenGL_Qt_Binding
qt_opengl
.cpp
)
TARGET_LINK_LIBRARIES
(
OpenGL_Qt_Binding
${
OpenCV_LIBS
}
${
OPENGL_LIBRARIES
}
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/cube4.avi
${
CMAKE_CURRENT_BINARY_DIR
}
/cube4.avi COPYONLY
)
samples/cpp/Qt_sample/
main
.cpp
→
samples/cpp/Qt_sample/
qt_opengl
.cpp
浏览文件 @
879c0196
...
...
@@ -33,14 +33,14 @@ static void help()
cout
<<
"
\n
This demo demonstrates the use of the Qt enhanced version of the highgui GUI interface
\n
"
" and dang if it doesn't throw in the use of of the POSIT 3D tracking algorithm too
\n
"
"It works off of the video: cube4.avi
\n
"
"Using OpenCV version
%s
\n
"
<<
CV_VERSION
<<
"
\n\n
"
" 1). This demo is mainly based on work from Javier Barandiaran Martirena
\n
"
" See this page http://code.opencv.org/projects/opencv/wiki/Posit.
\n
"
" 2). This is a demo to illustrate how to use **OpenGL Callback**.
\n
"
" 3). You need Qt binding to compile this sample with OpenGL support enabled.
\n
"
" 4). The features' detection is very basic and could highly be improved
\n
"
" (basic thresholding tuned for the specific video) but 2).
\n
"
" 5) THANKS TO Google Summer of Code 2010 for supporting this work!
\n
"
<<
endl
;
"Using OpenCV version "
<<
CV_VERSION
<<
"
\n\n
"
" 1). This demo is mainly based on work from Javier Barandiaran Martirena
\n
"
" See this page http://code.opencv.org/projects/opencv/wiki/Posit.
\n
"
" 2). This is a demo to illustrate how to use **OpenGL Callback**.
\n
"
" 3). You need Qt binding to compile this sample with OpenGL support enabled.
\n
"
" 4). The features' detection is very basic and could highly be improved
\n
"
" (basic thresholding tuned for the specific video) but 2).
\n
"
" 5) THANKS TO Google Summer of Code 2010 for supporting this work!
\n
"
<<
endl
;
}
#define FOCAL_LENGTH 600
...
...
@@ -88,7 +88,6 @@ static void renderCube(float size)
glEnd
();
}
static
void
on_opengl
(
void
*
param
)
{
//Draw the object with the estimated pose
...
...
@@ -121,8 +120,6 @@ static void foundCorners(vector<CvPoint2D32f> *srcImagePoints, const Mat& source
threshold
(
grayImage
,
grayImage
,
26
,
255
,
THRESH_BINARY_INV
);
//25
Mat
MgrayImage
=
grayImage
;
//For debug
//MgrayImage = MgrayImage.clone();//deep copy
vector
<
vector
<
Point
>
>
contours
;
vector
<
Vec4i
>
hierarchy
;
findContours
(
MgrayImage
,
contours
,
hierarchy
,
CV_RETR_EXTERNAL
,
CV_CHAIN_APPROX_NONE
);
...
...
@@ -199,21 +196,15 @@ static void foundCorners(vector<CvPoint2D32f> *srcImagePoints, const Mat& source
srcImagePoints
->
at
(
i
)
=
cvPoint2D32f
(
srcImagePoints_temp
.
at
(
i
).
x
-
source
.
cols
/
2
,
source
.
rows
/
2
-
srcImagePoints_temp
.
at
(
i
).
y
);
}
}
}
static
void
createOpenGLMatrixFrom
(
float
*
posePOSIT
,
const
CvMatr32f
&
rotationMatrix
,
const
CvVect32f
&
translationVector
)
{
//coordinate system returned is relative to the first 3D input point
for
(
int
f
=
0
;
f
<
3
;
f
++
)
{
for
(
int
c
=
0
;
c
<
3
;
c
++
)
{
posePOSIT
[
c
*
4
+
f
]
=
rotationMatrix
[
f
*
3
+
c
];
//transposed
}
}
posePOSIT
[
3
]
=
0.0
;
posePOSIT
[
7
]
=
0.0
;
posePOSIT
[
11
]
=
0.0
;
...
...
@@ -226,19 +217,27 @@ static void createOpenGLMatrixFrom(float *posePOSIT,const CvMatr32f &rotationMat
int
main
(
void
)
{
help
();
VideoCapture
video
(
"cube4.avi"
);
CV_Assert
(
video
.
isOpened
());
Mat
source
,
grayImage
;
string
fileName
=
"cube4.avi"
;
VideoCapture
video
(
fileName
);
if
(
!
video
.
isOpened
())
{
cerr
<<
"Video file "
<<
fileName
<<
" could not be opened"
<<
endl
;
return
EXIT_FAILURE
;
}
Mat
source
,
grayImage
;
video
>>
source
;
namedWindow
(
"original"
,
WINDOW_AUTOSIZE
|
CV_WINDOW_FREERATIO
);
namedWindow
(
"POSIT"
,
WINDOW_
AUTOSIZE
|
CV_WINDOW_FREERATIO
);
displayOverlay
(
"POSIT"
,
"We lost the 4 corners' detection quite often (the red circles disappear). This demo is only to illustrate how to use OpenGL callback.
\n
-- Press ESC to exit."
,
10000
);
namedWindow
(
"POSIT"
,
WINDOW_
OPENGL
|
CV_WINDOW_FREERATIO
);
resizeWindow
(
"POSIT"
,
source
.
cols
,
source
.
rows
);
float
OpenGLMatrix
[]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
setOpenGlDrawCallback
(
"POSIT"
,
on_opengl
,
OpenGLMatrix
);
displayOverlay
(
"POSIT"
,
"We lost the 4 corners' detection quite often (the red circles disappear)."
"This demo is only to illustrate how to use OpenGL callback.
\n
-- Press ESC to exit."
,
10000
);
float
OpenGLMatrix
[]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
setOpenGlDrawCallback
(
"POSIT"
,
on_opengl
,
OpenGLMatrix
);
vector
<
CvPoint3D32f
>
modelPoints
;
initPOSIT
(
&
modelPoints
);
...
...
@@ -248,19 +247,20 @@ int main(void)
CvMatr32f
rotation_matrix
=
new
float
[
9
];
CvVect32f
translation_vector
=
new
float
[
3
];
CvTermCriteria
criteria
=
cvTermCriteria
(
CV_TERMCRIT_EPS
|
CV_TERMCRIT_ITER
,
100
,
1.0e-4
f
);
vector
<
CvPoint2D32f
>
srcImagePoints
(
4
,
cvPoint2D32f
(
0
,
0
));
CvTermCriteria
criteria
=
cvTermCriteria
(
CV_TERMCRIT_EPS
|
CV_TERMCRIT_ITER
,
100
,
1e-4
f
);
vector
<
CvPoint2D32f
>
srcImagePoints
(
4
,
cvPoint2D32f
(
0
,
0
));
while
(
waitKey
(
33
)
!=
27
)
while
(
waitKey
(
33
)
!=
27
)
{
video
>>
source
;
imshow
(
"original"
,
source
);
if
(
source
.
empty
())
break
;
imshow
(
"original"
,
source
);
foundCorners
(
&
srcImagePoints
,
source
,
grayImage
);
cvPOSIT
(
positObject
,
&
srcImagePoints
[
0
],
FOCAL_LENGTH
,
criteria
,
rotation_matrix
,
translation_vector
);
createOpenGLMatrixFrom
(
OpenGLMatrix
,
rotation_matrix
,
translation_vector
);
createOpenGLMatrixFrom
(
OpenGLMatrix
,
rotation_matrix
,
translation_vector
);
imshow
(
"POSIT"
,
source
);
...
...
@@ -268,6 +268,7 @@ int main(void)
video
.
set
(
CV_CAP_PROP_POS_AVI_RATIO
,
0
);
}
setOpenGlDrawCallback
(
"POSIT"
,
0
,
0
);
destroyAllWindows
();
cvReleasePOSITObject
(
&
positObject
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录