This repository was archived by the owner on Apr 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsavefilethread.cpp
More file actions
56 lines (48 loc) · 1.44 KB
/
savefilethread.cpp
File metadata and controls
56 lines (48 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "savefilethread.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <stdio.h>
#include <QMessageBox>
#include <iostream>
#include <camera.h>
using namespace cv;
saveFileThread::saveFileThread(int times, string filename)
{
loop_number = times;
file = filename;
}
void saveFileThread::run()
{
Mat *frame; // do przechowywania obrazka
Camera *cam = Camera::getInstance(); // instancja kamery
double width = cam->getWidth(); // potrzebne parametry kamery
double height = cam->getHeight();
//stworzenie obiektu VideoWriter:
VideoWriter video(file,-1, 30, cvSize((int)width,(int)height), true);
// sprawdzenie czy plik do zapisu został otwarty:
if(!video.isOpened())
{
std::cout<< "błąd otwarcia pliku" << std::endl;
return;
}
int i =0;
std::cout << "zapis" << std::endl;
// zapisywanie do pliku:
while(i< loop_number * 300)
{
// pobranie klatki z kamery:
frame = cam->read();
// sprawdzenie czy klatka została pobrana:
if(frame->data == NULL){
std::cout << "klatka pusta" << std::endl;
video.release();
return;
}
// zapis do pliku:
video.write(*frame);
std::cout << i << std::endl;
i++;
}
video.release();
std::cout << "to ja thread! " << loop_number << std::endl;
}