Browse Source

test video io

master
zara 3 years ago
parent
commit
d6d0e227c5
  1. 4
      CMakeLists.txt
  2. 11
      mainwindow.cpp
  3. 15
      mainwindow.ui
  4. 4
      readme.md

4
CMakeLists.txt

@ -59,8 +59,8 @@ if(QT_VERSION_MAJOR EQUAL 6) @@ -59,8 +59,8 @@ if(QT_VERSION_MAJOR EQUAL 6)
endif()
include_directories("C:/msys64/mingw64/include/opencv4")
include_directories("C:/msys64/mingw64/include/opencv4")# opencv2
file(GLOB CVLIBS "C:/msys64/mingw64/lib/libopencv*.a")
file(GLOB CVLIBS "C:/msys64/mingw64/lib/libopencv*.a")# libopencv*.a
target_link_libraries(cap0 PRIVATE ${CVLIBS})

11
mainwindow.cpp

@ -6,7 +6,7 @@ MainWindow::MainWindow(QWidget *parent) @@ -6,7 +6,7 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
cap = new VideoCapture(0);
cap = new VideoCapture();
onCap = false;
vt = new QTimer(this);
// vt->start(20);
@ -26,6 +26,15 @@ void MainWindow::on_pushButton_clicked() @@ -26,6 +26,15 @@ void MainWindow::on_pushButton_clicked()
onCap = false;
}
else{
bool isnum;
int z = ui->lineEdit->text().toUInt(&isnum);
if(isnum){
cap->open(z);
}
else{
cap->open(ui->lineEdit->text().toStdString());
}
vt->start(20);
onCap = true;
}

15
mainwindow.ui

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<y>90</y>
<width>80</width>
<height>21</height>
</rect>
@ -40,18 +40,15 @@ @@ -40,18 +40,15 @@
<string/>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>80</width>
<height>21</height>
<x>10</x>
<y>30</y>
<width>113</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>save</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">

4
readme.md

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
# opencv 练习工程
1. 使用mingw64工具链
2. 使用qt相关库
Loading…
Cancel
Save