MythTV
master
mythtv
programs
mythcommflag
ClassicSceneChangeDetector.cpp
Go to the documentation of this file.
1
#include <algorithm>
2
3
#include "
ClassicSceneChangeDetector.h
"
4
#include "
Histogram.h
"
5
6
ClassicSceneChangeDetector::ClassicSceneChangeDetector
(
unsigned
int
width,
7
unsigned
int
height,
unsigned
int
commdetectborder_in,
8
unsigned
int
xspacing_in,
unsigned
int
yspacing_in):
9
SceneChangeDetectorBase
(width,height),
10
m_histogram(new
Histogram
),
11
m_previousHistogram(new
Histogram
),
12
m_xspacing(xspacing_in),
13
m_yspacing(yspacing_in),
14
m_commdetectborder(commdetectborder_in)
15
{
16
}
17
18
ClassicSceneChangeDetector::~ClassicSceneChangeDetector
()
19
{
20
delete
m_histogram
;
21
delete
m_previousHistogram
;
22
}
23
24
void
ClassicSceneChangeDetector::deleteLater
(
void
)
25
{
26
SceneChangeDetectorBase::deleteLater();
27
}
28
29
void
ClassicSceneChangeDetector::processFrame
(
MythVideoFrame
* frame)
30
{
31
m_histogram
->
generateFromImage
(frame,
m_width
,
m_height
,
m_commdetectborder
,
32
m_width
-
m_commdetectborder
,
m_commdetectborder
,
33
m_height
-
m_commdetectborder
,
m_xspacing
,
m_yspacing
);
34
float
similar =
m_histogram
->
calculateSimilarityWith
(*
m_previousHistogram
);
35
36
bool
isSceneChange = (similar < .85F && !
m_previousFrameWasSceneChange
);
37
38
emit
haveNewInformation
(
m_frameNumber
,isSceneChange,similar);
39
m_previousFrameWasSceneChange
= isSceneChange;
40
41
std::swap(
m_histogram
,
m_previousHistogram
);
42
m_frameNumber
++;
43
}
44
45
/* vim: set expandtab tabstop=4 shiftwidth=4: */
46
ClassicSceneChangeDetector::ClassicSceneChangeDetector
ClassicSceneChangeDetector(unsigned int width, unsigned int height, unsigned int commdetectborder, unsigned int xspacing, unsigned int yspacing)
Definition:
ClassicSceneChangeDetector.cpp:6
ClassicSceneChangeDetector::m_histogram
Histogram * m_histogram
Definition:
ClassicSceneChangeDetector.h:22
Histogram::generateFromImage
void generateFromImage(MythVideoFrame *frame, unsigned int frameWidth, unsigned int frameHeight, unsigned int minScanX, unsigned int maxScanX, unsigned int minScanY, unsigned int maxScanY, unsigned int XSpacing, unsigned int YSpacing)
Definition:
Histogram.cpp:10
ClassicSceneChangeDetector::processFrame
void processFrame(MythVideoFrame *frame) override
Definition:
ClassicSceneChangeDetector.cpp:29
SceneChangeDetectorBase::haveNewInformation
void haveNewInformation(unsigned int framenum, bool scenechange, float debugValue=0.0)
ClassicSceneChangeDetector::m_frameNumber
unsigned int m_frameNumber
Definition:
ClassicSceneChangeDetector.h:24
ClassicSceneChangeDetector::deleteLater
virtual void deleteLater(void)
Definition:
ClassicSceneChangeDetector.cpp:24
Histogram::calculateSimilarityWith
float calculateSimilarityWith(const Histogram &other) const
Definition:
Histogram.cpp:65
SceneChangeDetectorBase::m_height
unsigned int m_height
Definition:
SceneChangeDetectorBase.h:25
ClassicSceneChangeDetector::~ClassicSceneChangeDetector
~ClassicSceneChangeDetector() override
Definition:
ClassicSceneChangeDetector.cpp:18
SceneChangeDetectorBase
Definition:
SceneChangeDetectorBase.h:7
ClassicSceneChangeDetector::m_yspacing
unsigned int m_yspacing
Definition:
ClassicSceneChangeDetector.h:26
Histogram.h
ClassicSceneChangeDetector::m_xspacing
unsigned int m_xspacing
Definition:
ClassicSceneChangeDetector.h:26
SceneChangeDetectorBase::m_width
unsigned int m_width
Definition:
SceneChangeDetectorBase.h:25
Histogram
Definition:
Histogram.h:6
ClassicSceneChangeDetector::m_previousHistogram
Histogram * m_previousHistogram
Definition:
ClassicSceneChangeDetector.h:23
ClassicSceneChangeDetector::m_commdetectborder
unsigned int m_commdetectborder
Definition:
ClassicSceneChangeDetector.h:27
ClassicSceneChangeDetector.h
MythVideoFrame
Definition:
mythframe.h:87
ClassicSceneChangeDetector::m_previousFrameWasSceneChange
bool m_previousFrameWasSceneChange
Definition:
ClassicSceneChangeDetector.h:25
Generated on Tue Jan 7 2025 03:18:39 for MythTV by
1.8.17