-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoProcessor.cpp
More file actions
74 lines (58 loc) · 1.89 KB
/
Copy pathVideoProcessor.cpp
File metadata and controls
74 lines (58 loc) · 1.89 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "VideoProcessor.h"
VideoProcessor::VideoProcessor(QObject *parent) : QThread(parent)
{
}
void VideoProcessor::setVideoPath(const QString &path)
{
videoPath = path;
}
void VideoProcessor::setOutputDir(const QString &dir)
{
outputDir = dir;
}
void VideoProcessor::stopProcessing()
{
stopRequested = true;
}
void VideoProcessor::run()
{
stopRequested = false;
if(videoPath.isEmpty()) {
emit errorOccurred("Video dosyası seçilmedi!");
return;
}
// Çıktı dizinini temizle
// VideoProcessor::run() fonksiyonunda video açıldıktan sonra:
cv::VideoCapture video(videoPath.toStdString());
if(!video.isOpened()) {
emit errorOccurred("Video açılamadı: " + videoPath);
return;
}
// Toplam frame sayısını al ve sinyal gönder
int totalFrames = static_cast<int>(video.get(cv::CAP_PROP_FRAME_COUNT));
double fps = video.get(cv::CAP_PROP_FPS);
emit totalFramesDetected(totalFrames);
emit logMessage(QString("Video bilgileri: %1 kare, %2 FPS").arg(totalFrames).arg(fps));
int frameNumber = 0;
cv::Mat frame;
emit logMessage("Video kareleri ayrıştırılıyor...");
while(!stopRequested) {
if(!video.read(frame)) {
break;
}
QString filename = QString("%1/frame_%2.jpg").arg(outputDir).arg(frameNumber);
if(!cv::imwrite(filename.toStdString(), frame)) {
emit errorOccurred("Frame kaydedilemedi: " + filename);
break;
}
emit progressUpdated(frameNumber);
frameNumber++;
}
video.release();
if(stopRequested) {
emit logMessage("İşlem kullanıcı tarafından durduruldu");
} else {
emit logMessage(QString("İşlem tamamlandı! Toplam % kare ayrıştırıldı").arg(frameNumber));
}
emit finished();
}