Skip to content

Commit 3303efb

Browse files
committedJun 27, 2022
CX05: Fix link library bug of OpenCV
1 parent 655cbbe commit 3303efb

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed
 

‎CMake/cxInitializeLibraries.cmake

+9
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,12 @@ macro(cx_initialize_deformableslam)
293293
find_package(DeformableSLAM REQUIRED)
294294
include(${DeformableSLAM_USE_FILE})
295295
endmacro()
296+
297+
###############################################################################
298+
# Initialize Pangolin library
299+
# Find the package.
300+
###############################################################################
301+
macro(cx_initialize_Pangolin)
302+
find_package(Pangolin REQUIRED )
303+
include_directories(${Pangolin_INCLUDE_DIRS})
304+
endmacro()

‎source/plugins/org.custusx.vslam/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ project(org_custusx_vslam)
22

33
cx_initialize_deformableslam()
44
cx_initialize_opencv()
5+
cx_initialize_Pangolin()
56

67
set(PLUGIN_export_directive "${PROJECT_NAME}_EXPORT")
78

@@ -40,9 +41,11 @@ set(PLUGIN_target_libraries
4041
cxResourceVisualization
4142
cxLogicManager
4243
#cxLogicManager
43-
#cxGrabber
44-
Qt5::Widgets
44+
#cxGrabber
45+
Qt5::Widgets
4546
DeformableSLAM
47+
${Pangolin_LIBRARIES}
48+
${OpenCV_LIBS}
4649
)
4750

4851
set(PLUGIN_OUTPUT_DIR "")

‎source/plugins/org.custusx.vslam/cxVslamWidget.cpp

+22-10
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt
1212
#include "cxVslamWidget.h"
1313
#include <QVBoxLayout>
1414
#include "opencv2/core/core.hpp"
15+
#include "opencv2/opencv.hpp"
1516
#include "Modules/Common/System.h"
16-
namespace cv
17-
{
18-
class VideoCapture;
19-
}
17+
2018
namespace cx
2119
{
2220

@@ -38,14 +36,28 @@ VslamWidget::~VslamWidget()
3836
void VslamWidget::startVslam()
3937
{
4038
qDebug()<<"开始规划了";
41-
/*
42-
cv::VideoCapture cap;
39+
cv::VideoCapture cap; // Open input
4340
cap.open("/home/shu/HamlynDatasetShort/f7phantom/f7_dynamic_deint_L.avi");
44-
std::cout<<"cap status"<<cap.isOpened()<<std::endl;
45-
cap.set(cv::CAP_PROP_FRAME_WIDTH, 640);
46-
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
41+
if(!cap.isOpened()){
42+
std::cout << "Error opening video stream or file" << std::endl;
43+
}
44+
while(1){
45+
cv::Mat frame;
46+
// Capture frame-by-frame
47+
cap >> frame;
48+
// If the frame is empty, break immediately
49+
if (frame.empty())
50+
break;
51+
// Display the resulting frame
52+
cv::imshow( "Frame", frame );
53+
// Press ESC on keyboard to exit
54+
char c=(char)cv::waitKey(25);
55+
if(c==27)
56+
break;
57+
}
58+
// When everything done, release the video capture object
59+
cap.release();
4760

48-
*/
4961
}
5062

5163
QString VslamWidget::defaultWhatsThis() const

0 commit comments

Comments
 (0)