Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
3df6b6fd
Commit
3df6b6fd
authored
Mar 25, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added self-contained motion jpeg encoder (filename should end with .avi; fourcc should be "MJPG"
parent
0545aeb1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
153 additions
and
62 deletions
+153
-62
CMakeLists.txt
modules/videoio/CMakeLists.txt
+2
-0
videoio.hpp
modules/videoio/include/opencv2/videoio.hpp
+6
-2
cap.cpp
modules/videoio/src/cap.cpp
+75
-57
cap_dshow.hpp
modules/videoio/src/cap_dshow.hpp
+1
-1
cap_intelperc.hpp
modules/videoio/src/cap_intelperc.hpp
+1
-1
cap_mjpeg_decoder.cpp
modules/videoio/src/cap_mjpeg_decoder.cpp
+52
-0
cap_mjpeg_encoder.cpp
modules/videoio/src/cap_mjpeg_encoder.cpp
+0
-0
precomp.hpp
modules/videoio/src/precomp.hpp
+16
-1
No files found.
modules/videoio/CMakeLists.txt
View file @
3df6b6fd
...
...
@@ -27,6 +27,8 @@ set(videoio_hdrs
set
(
videoio_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/src/cap.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/src/cap_images.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/src/cap_mjpeg_encoder.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/src/cap_mjpeg_decoder.cpp
)
file
(
GLOB videoio_ext_hdrs
...
...
modules/videoio/include/opencv2/videoio.hpp
View file @
3df6b6fd
...
...
@@ -586,10 +586,10 @@ public:
protected
:
Ptr
<
CvCapture
>
cap
;
Ptr
<
IVideoCapture
>
icap
;
private
:
static
Ptr
<
IVideoCapture
>
createCameraCapture
(
int
index
);
};
class
IVideoWriter
;
/** @brief Video writer class.
*/
class
CV_EXPORTS_W
VideoWriter
...
...
@@ -651,6 +651,10 @@ public:
protected
:
Ptr
<
CvVideoWriter
>
writer
;
Ptr
<
IVideoWriter
>
iwriter
;
static
Ptr
<
IVideoWriter
>
create
(
const
String
&
filename
,
int
fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
=
true
);
};
template
<>
CV_EXPORTS
void
DefaultDeleter
<
CvCapture
>::
operator
()(
CvCapture
*
obj
)
const
;
...
...
modules/videoio/src/cap.cpp
View file @
3df6b6fd
...
...
@@ -499,6 +499,67 @@ CV_IMPL void cvReleaseVideoWriter( CvVideoWriter** pwriter )
namespace
cv
{
static
Ptr
<
IVideoCapture
>
IVideoCapture_create
(
int
index
)
{
int
domains
[]
=
{
#ifdef HAVE_DSHOW
CV_CAP_DSHOW
,
#endif
#ifdef HAVE_INTELPERC
CV_CAP_INTELPERC
,
#endif
-
1
,
-
1
};
// interpret preferred interface (0 = autodetect)
int
pref
=
(
index
/
100
)
*
100
;
if
(
pref
)
{
domains
[
0
]
=
pref
;
index
%=
100
;
domains
[
1
]
=-
1
;
}
// try every possibly installed camera API
for
(
int
i
=
0
;
domains
[
i
]
>=
0
;
i
++
)
{
#if defined(HAVE_DSHOW) || \
defined(HAVE_INTELPERC) || \
(0)
Ptr
<
IVideoCapture
>
capture
;
switch
(
domains
[
i
])
{
#ifdef HAVE_DSHOW
case
CV_CAP_DSHOW
:
capture
=
makePtr
<
VideoCapture_DShow
>
(
index
);
break
;
// CV_CAP_DSHOW
#endif
#ifdef HAVE_INTELPERC
case
CV_CAP_INTELPERC
:
capture
=
makePtr
<
VideoCapture_IntelPerC
>
();
break
;
// CV_CAP_INTEL_PERC
#endif
}
if
(
capture
&&
capture
->
isOpened
())
return
capture
;
#endif
}
// failed open a camera
return
Ptr
<
IVideoCapture
>
();
}
static
Ptr
<
IVideoWriter
>
IVideoWriter_create
(
const
String
&
filename
,
int
_fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
)
{
Ptr
<
IVideoWriter
>
iwriter
;
if
(
_fourcc
==
CV_FOURCC
(
'M'
,
'J'
,
'P'
,
'G'
)
)
iwriter
=
createMotionJpegWriter
(
filename
,
fps
,
frameSize
,
isColor
);
return
iwriter
;
}
VideoCapture
::
VideoCapture
()
{}
...
...
@@ -528,7 +589,7 @@ bool VideoCapture::open(const String& filename)
bool
VideoCapture
::
open
(
int
device
)
{
if
(
isOpened
())
release
();
icap
=
createCameraCaptur
e
(
device
);
icap
=
IVideoCapture_creat
e
(
device
);
if
(
!
icap
.
empty
())
return
true
;
cap
.
reset
(
cvCreateCameraCapture
(
device
));
...
...
@@ -609,59 +670,6 @@ double VideoCapture::get(int propId) const
return
icvGetCaptureProperty
(
cap
,
propId
);
}
Ptr
<
IVideoCapture
>
VideoCapture
::
createCameraCapture
(
int
index
)
{
int
domains
[]
=
{
#ifdef HAVE_DSHOW
CV_CAP_DSHOW
,
#endif
#ifdef HAVE_INTELPERC
CV_CAP_INTELPERC
,
#endif
-
1
,
-
1
};
// interpret preferred interface (0 = autodetect)
int
pref
=
(
index
/
100
)
*
100
;
if
(
pref
)
{
domains
[
0
]
=
pref
;
index
%=
100
;
domains
[
1
]
=-
1
;
}
// try every possibly installed camera API
for
(
int
i
=
0
;
domains
[
i
]
>=
0
;
i
++
)
{
#if defined(HAVE_DSHOW) || \
defined(HAVE_INTELPERC) || \
(0)
Ptr
<
IVideoCapture
>
capture
;
switch
(
domains
[
i
])
{
#ifdef HAVE_DSHOW
case
CV_CAP_DSHOW
:
capture
=
makePtr
<
VideoCapture_DShow
>
(
index
);
if
(
capture
&&
capture
.
dynamicCast
<
VideoCapture_DShow
>
()
->
isOpened
())
return
capture
;
break
;
// CV_CAP_DSHOW
#endif
#ifdef HAVE_INTELPERC
case
CV_CAP_INTELPERC
:
capture
=
makePtr
<
VideoCapture_IntelPerC
>
();
if
(
capture
&&
capture
.
dynamicCast
<
VideoCapture_IntelPerC
>
()
->
isOpened
())
return
capture
;
break
;
// CV_CAP_INTEL_PERC
#endif
}
#endif
}
// failed open a camera
return
Ptr
<
IVideoCapture
>
();
}
VideoWriter
::
VideoWriter
()
{}
...
...
@@ -673,6 +681,7 @@ VideoWriter::VideoWriter(const String& filename, int _fourcc, double fps, Size f
void
VideoWriter
::
release
()
{
iwriter
.
release
();
writer
.
release
();
}
...
...
@@ -683,19 +692,28 @@ VideoWriter::~VideoWriter()
bool
VideoWriter
::
open
(
const
String
&
filename
,
int
_fourcc
,
double
fps
,
Size
frameSize
,
bool
isColor
)
{
if
(
isOpened
())
release
();
iwriter
=
IVideoWriter_create
(
filename
,
_fourcc
,
fps
,
frameSize
,
isColor
);
if
(
!
iwriter
.
empty
())
return
true
;
writer
.
reset
(
cvCreateVideoWriter
(
filename
.
c_str
(),
_fourcc
,
fps
,
frameSize
,
isColor
));
return
isOpened
();
}
bool
VideoWriter
::
isOpened
()
const
{
return
!
writer
.
empty
();
return
!
iwriter
.
empty
()
||
!
writer
.
empty
();
}
void
VideoWriter
::
write
(
const
Mat
&
image
)
{
IplImage
_img
=
image
;
cvWriteFrame
(
writer
,
&
_img
);
if
(
iwriter
)
iwriter
->
write
(
image
);
else
{
IplImage
_img
=
image
;
cvWriteFrame
(
writer
,
&
_img
);
}
}
VideoWriter
&
VideoWriter
::
operator
<<
(
const
Mat
&
image
)
...
...
modules/videoio/src/cap_dshow.hpp
View file @
3df6b6fd
...
...
@@ -32,7 +32,7 @@ public:
virtual
bool
grabFrame
();
virtual
bool
retrieveFrame
(
int
outputType
,
OutputArray
frame
);
virtual
int
getCaptureDomain
();
bool
isOpened
()
const
;
virtual
bool
isOpened
()
const
;
protected
:
void
open
(
int
index
);
void
close
();
...
...
modules/videoio/src/cap_intelperc.hpp
View file @
3df6b6fd
...
...
@@ -100,7 +100,7 @@ public:
virtual
bool
grabFrame
();
virtual
bool
retrieveFrame
(
int
outputType
,
OutputArray
frame
);
virtual
int
getCaptureDomain
();
bool
isOpened
()
const
;
virtual
bool
isOpened
()
const
;
protected
:
bool
m_contextOpened
;
...
...
modules/videoio/src/cap_mjpeg_decoder.cpp
0 → 100644
View file @
3df6b6fd
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2015, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
namespace
cv
{
Ptr
<
IVideoCapture
>
createMotionJpegCapture
(
const
String
&
filename
)
{
return
Ptr
<
IVideoCapture
>
();
}
}
modules/videoio/src/cap_mjpeg_encoder.cpp
0 → 100644
View file @
3df6b6fd
This diff is collapsed.
Click to expand it.
modules/videoio/src/precomp.hpp
View file @
3df6b6fd
...
...
@@ -168,9 +168,24 @@ namespace cv
virtual
double
getProperty
(
int
)
const
{
return
0
;
}
virtual
bool
setProperty
(
int
,
double
)
{
return
0
;
}
virtual
bool
grabFrame
()
=
0
;
virtual
bool
retrieveFrame
(
int
,
cv
::
OutputArray
)
=
0
;
virtual
bool
retrieveFrame
(
int
,
OutputArray
)
=
0
;
virtual
bool
isOpened
()
const
=
0
;
virtual
int
getCaptureDomain
()
{
return
CAP_ANY
;
}
// Return the type of the capture object: CAP_VFW, etc...
};
class
IVideoWriter
{
public
:
virtual
~
IVideoWriter
()
{}
virtual
double
getProperty
(
int
)
const
{
return
0
;
}
virtual
bool
setProperty
(
int
,
double
)
{
return
0
;
}
virtual
bool
isOpened
()
const
=
0
;
virtual
void
write
(
InputArray
)
=
0
;
};
Ptr
<
IVideoCapture
>
createMotionJpegCapture
(
const
String
&
filename
);
Ptr
<
IVideoWriter
>
createMotionJpegWriter
(
const
String
&
filename
,
double
fps
,
Size
frameSize
,
bool
iscolor
);
};
#endif
/* __VIDEOIO_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment