Mergin itseez
@@ -9,13 +9,12 @@ ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera)
|
||||
|
||||
ocv_clear_vars(GRFMT_LIBS)
|
||||
|
||||
if(WITH_PNG OR WITH_TIFF OR WITH_OPENEXR)
|
||||
ocv_include_directories(${ZLIB_INCLUDE_DIR})
|
||||
if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
|
||||
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WITH_JPEG)
|
||||
add_definitions(-DHAVE_JPEG)
|
||||
if(HAVE_JPEG)
|
||||
ocv_include_directories(${JPEG_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
|
||||
endif()
|
||||
@@ -26,27 +25,23 @@ if(WITH_WEBP)
|
||||
list(APPEND GRFMT_LIBS ${WEBP_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WITH_PNG)
|
||||
add_definitions(-DHAVE_PNG)
|
||||
if(HAVE_PNG)
|
||||
add_definitions(${PNG_DEFINITIONS})
|
||||
ocv_include_directories(${PNG_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${PNG_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WITH_TIFF)
|
||||
add_definitions(-DHAVE_TIFF)
|
||||
if(HAVE_TIFF)
|
||||
ocv_include_directories(${TIFF_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${TIFF_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WITH_JASPER)
|
||||
add_definitions(-DHAVE_JASPER)
|
||||
if(HAVE_JASPER)
|
||||
ocv_include_directories(${JASPER_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${JASPER_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WITH_OPENEXR)
|
||||
add_definitions(-DHAVE_OPENEXR)
|
||||
if(HAVE_OPENEXR)
|
||||
include_directories(SYSTEM ${OPENEXR_INCLUDE_PATHS})
|
||||
list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
|
||||
endif()
|
||||
@@ -71,7 +66,6 @@ set(highgui_srcs
|
||||
src/cap_images.cpp
|
||||
src/cap_ffmpeg.cpp
|
||||
src/loadsave.cpp
|
||||
src/precomp.cpp
|
||||
src/utils.cpp
|
||||
src/window.cpp
|
||||
)
|
||||
@@ -116,16 +110,12 @@ elseif(HAVE_WIN32UI)
|
||||
list(APPEND highgui_srcs src/window_w32.cpp)
|
||||
elseif(HAVE_GTK)
|
||||
list(APPEND highgui_srcs src/window_gtk.cpp)
|
||||
elseif(APPLE)
|
||||
if(WITH_CARBON)
|
||||
add_definitions(-DHAVE_CARBON=1)
|
||||
list(APPEND highgui_srcs src/window_carbon.cpp)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime")
|
||||
elseif(NOT IOS)
|
||||
add_definitions(-DHAVE_COCOA=1)
|
||||
list(APPEND highgui_srcs src/window_cocoa.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
||||
endif()
|
||||
elseif(HAVE_CARBON)
|
||||
list(APPEND highgui_srcs src/window_carbon.cpp)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime")
|
||||
elseif(HAVE_COCOA)
|
||||
list(APPEND highgui_srcs src/window_cocoa.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT ARM)
|
||||
@@ -205,6 +195,7 @@ endif(HAVE_FFMPEG)
|
||||
|
||||
if(HAVE_PVAPI)
|
||||
add_definitions(-DHAVE_PVAPI)
|
||||
add_definitions(${PVAPI_DEFINITIONS})
|
||||
ocv_include_directories(${PVAPI_INCLUDE_PATH})
|
||||
set(highgui_srcs src/cap_pvapi.cpp ${highgui_srcs})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${PVAPI_LIBRARY})
|
||||
@@ -218,24 +209,22 @@ if(HAVE_GIGE_API)
|
||||
list(APPEND highgui_srcs src/cap_giganetix.cpp)
|
||||
endif(HAVE_GIGE_API)
|
||||
|
||||
if(WITH_AVFOUNDATION)
|
||||
add_definitions(-DHAVE_AVFOUNDATION=1)
|
||||
if(HAVE_AVFOUNDATION)
|
||||
list(APPEND highgui_srcs src/cap_avfoundation.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
|
||||
elseif(APPLE)
|
||||
add_definitions(-DHAVE_QUICKTIME=1)
|
||||
if(WITH_QUICKTIME)
|
||||
list(APPEND highgui_srcs src/cap_qt.cpp)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore")
|
||||
else()
|
||||
list(APPEND highgui_srcs src/cap_qtkit.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_QUICKTIME)
|
||||
list(APPEND highgui_srcs src/cap_qt.cpp)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore")
|
||||
elseif(HAVE_QTKIT)
|
||||
list(APPEND highgui_srcs src/cap_qtkit.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit")
|
||||
endif()
|
||||
|
||||
if(IOS)
|
||||
add_definitions(-DHAVE_IOS=1)
|
||||
list(APPEND highgui_srcs src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm)
|
||||
list(APPEND highgui_srcs src/ios_conversions.mm src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary")
|
||||
endif()
|
||||
|
||||
@@ -305,11 +294,6 @@ if(WIN32 AND WITH_FFMPEG)
|
||||
set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
|
||||
set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
|
||||
|
||||
#if(MSVC AND CMAKE_VERSION VERSION_GREATER "2.8.2")
|
||||
# add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/$<CONFIGURATION>/${ffmpeg_bare_name_ver}"
|
||||
# COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
#else
|
||||
if(MSVC_IDE)
|
||||
add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}"
|
||||
|
@@ -334,5 +334,3 @@ See below various examples of the ``createButton`` function call: ::
|
||||
createButton("button6",callbackButton2,NULL,CV_PUSH_BUTTON,1);
|
||||
|
||||
..
|
||||
|
||||
|
||||
|
@@ -223,6 +223,15 @@ The class provides C++ API for capturing video from cameras or for reading video
|
||||
|
||||
.. note:: In C API the black-box structure ``CvCapture`` is used instead of ``VideoCapture``.
|
||||
|
||||
.. note::
|
||||
|
||||
* A basic sample on using the VideoCapture interface can be found at opencv_source_code/samples/cpp/starter_video.cpp
|
||||
* Another basic video processing sample can be found at opencv_source_code/samples/cpp/video_dmtx.cpp
|
||||
|
||||
* (Python) A basic sample on using the VideoCapture interface can be found at opencv_source_code/samples/python2/video.py
|
||||
* (Python) Another basic video processing sample can be found at opencv_source_code/samples/python2/video_dmtx.py
|
||||
* (Python) A multi threaded video processing sample can be found at opencv_source_code/samples/python2/video_threaded.py
|
||||
|
||||
|
||||
VideoCapture::VideoCapture
|
||||
------------------------------
|
||||
@@ -530,4 +539,3 @@ Writes the next video frame
|
||||
:param image: The written frame
|
||||
|
||||
The functions/methods write the specified image to video file. It must have the same size as has been specified when opening the video writer.
|
||||
|
||||
|
@@ -9,6 +9,8 @@ Creates a trackbar and attaches it to the specified window.
|
||||
|
||||
.. ocv:function:: int createTrackbar( const String& trackbarname, const String& winname, int* value, int count, TrackbarCallback onChange=0, void* userdata=0)
|
||||
|
||||
.. ocv:pyfunction:: cv2.createTrackbar(trackbarName, windowName, value, count, onChange) -> None
|
||||
|
||||
.. ocv:cfunction:: int cvCreateTrackbar( const char* trackbar_name, const char* window_name, int* value, int count, CvTrackbarCallback on_change=NULL )
|
||||
|
||||
:param trackbarname: Name of the created trackbar.
|
||||
@@ -31,6 +33,10 @@ The function ``createTrackbar`` creates a trackbar (a slider or range control) w
|
||||
|
||||
Clicking the label of each trackbar enables editing the trackbar values manually.
|
||||
|
||||
.. note::
|
||||
|
||||
* An example of using the trackbar functionality can be found at opencv_source_code/samples/cpp/connected_components.cpp
|
||||
|
||||
getTrackbarPos
|
||||
------------------
|
||||
Returns the trackbar position.
|
||||
@@ -73,6 +79,10 @@ The function ``imshow`` displays an image in the specified window. If the window
|
||||
|
||||
* If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].
|
||||
|
||||
If window was created with OpenGL support, ``imshow`` also support :ocv:class:`ogl::Buffer` , :ocv:class:`ogl::Texture2D` and :ocv:class:`gpu::GpuMat` as input.
|
||||
|
||||
.. note:: This function should be followed by ``waitKey`` function which displays the image for specified milliseconds. Otherwise, it won't display the image. For example, ``waitKey(0)`` will display the window infinitely until any keypress (it is suitable for image display). ``waitKey(25)`` will display a frame for 25 ms, after which display will be automatically closed. (If you put it in a loop to read videos, it will display the video frame-by-frame)
|
||||
|
||||
|
||||
namedWindow
|
||||
---------------
|
||||
@@ -86,7 +96,13 @@ Creates a window.
|
||||
|
||||
:param name: Name of the window in the window caption that may be used as a window identifier.
|
||||
|
||||
:param flags: Flags of the window. Currently the only supported flag is ``CV_WINDOW_AUTOSIZE`` . If this is set, the window size is automatically adjusted to fit the displayed image (see :ocv:func:`imshow` ), and you cannot change the window size manually.
|
||||
:param flags: Flags of the window. The supported flags are:
|
||||
|
||||
* **WINDOW_NORMAL** If this is set, the user can resize the window (no constraint).
|
||||
|
||||
* **WINDOW_AUTOSIZE** If this is set, the window size is automatically adjusted to fit the displayed image (see :ocv:func:`imshow` ), and you cannot change the window size manually.
|
||||
|
||||
* **WINDOW_OPENGL** If this is set, the window will be created with OpenGL support.
|
||||
|
||||
The function ``namedWindow`` creates a window that can be used as a placeholder for images and trackbars. Created windows are referred to by their names.
|
||||
|
||||
@@ -181,6 +197,8 @@ Sets mouse handler for the specified window
|
||||
|
||||
.. ocv:function:: void setMouseCallback( const String& winname, MouseCallback onMouse, void* userdata=0 )
|
||||
|
||||
.. ocv:pyfunction:: cv2.setMouseCallback(windowName, onMouse [, param]) -> None
|
||||
|
||||
.. ocv:cfunction:: void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, void* param=NULL )
|
||||
|
||||
:param winname: Window name
|
||||
@@ -234,3 +252,31 @@ The function ``waitKey`` waits for a key event infinitely (when
|
||||
.. note::
|
||||
|
||||
The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active.
|
||||
|
||||
setOpenGlDrawCallback
|
||||
---------------------
|
||||
Set OpenGL render handler for the specified window.
|
||||
|
||||
.. ocv:function:: void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0)
|
||||
|
||||
:param winname: Window name
|
||||
|
||||
:param onOpenGlDraw: Draw callback.
|
||||
|
||||
:param userdata: The optional parameter passed to the callback.
|
||||
|
||||
setOpenGlContext
|
||||
----------------
|
||||
Sets the specified window as current OpenGL context.
|
||||
|
||||
.. ocv:function:: void setOpenGlContext(const String& winname)
|
||||
|
||||
:param winname: Window name
|
||||
|
||||
updateWindow
|
||||
------------
|
||||
Force window to redraw its context and call draw callback ( :ocv:func:`setOpenGlDrawCallback` ).
|
||||
|
||||
.. ocv:function:: void updateWindow(const String& winname)
|
||||
|
||||
:param winname: Window name
|
||||
|
@@ -544,8 +544,8 @@ protected:
|
||||
Ptr<CvVideoWriter> writer;
|
||||
};
|
||||
|
||||
template<> CV_EXPORTS void Ptr<CvCapture>::delete_obj();
|
||||
template<> CV_EXPORTS void Ptr<CvVideoWriter>::delete_obj();
|
||||
template<> CV_EXPORTS void DefaultDeleter<CvCapture>::operator ()(CvCapture* obj) const;
|
||||
template<> CV_EXPORTS void DefaultDeleter<CvVideoWriter>::operator ()(CvVideoWriter* obj) const;
|
||||
|
||||
} // cv
|
||||
|
||||
|
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* cap_ios.h
|
||||
* For iOS video I/O
|
||||
/* For iOS video I/O
|
||||
* by Eduard Feicho on 29/07/12
|
||||
* Copyright 2012. All rights reserved.
|
||||
*
|
||||
@@ -90,6 +88,12 @@
|
||||
- (void)createVideoPreviewLayer;
|
||||
- (void)updateOrientation;
|
||||
|
||||
- (void)lockFocus;
|
||||
- (void)unlockFocus;
|
||||
- (void)lockExposure;
|
||||
- (void)unlockExposure;
|
||||
- (void)lockBalance;
|
||||
- (void)unlockBalance;
|
||||
|
||||
@end
|
||||
|
||||
@@ -116,6 +120,7 @@
|
||||
BOOL grayscaleMode;
|
||||
|
||||
BOOL recordVideo;
|
||||
BOOL rotateVideo;
|
||||
AVAssetWriterInput* recordAssetWriterInput;
|
||||
AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
|
||||
AVAssetWriter* recordAssetWriter;
|
||||
@@ -128,6 +133,7 @@
|
||||
@property (nonatomic, assign) BOOL grayscaleMode;
|
||||
|
||||
@property (nonatomic, assign) BOOL recordVideo;
|
||||
@property (nonatomic, assign) BOOL rotateVideo;
|
||||
@property (nonatomic, retain) AVAssetWriterInput* recordAssetWriterInput;
|
||||
@property (nonatomic, retain) AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
|
||||
@property (nonatomic, retain) AVAssetWriter* recordAssetWriter;
|
||||
|
@@ -45,4 +45,4 @@
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
@@ -559,9 +559,11 @@ CVAPI(int) cvGetCaptureDomain( CvCapture* capture);
|
||||
/* "black box" video file writer structure */
|
||||
typedef struct CvVideoWriter CvVideoWriter;
|
||||
|
||||
#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24))
|
||||
|
||||
CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
|
||||
{
|
||||
return (c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24);
|
||||
return CV_FOURCC_MACRO(c1, c2, c3, c4);
|
||||
}
|
||||
|
||||
#define CV_FOURCC_PROMPT -1 /* Open Codec Selection Dialog (Windows only) */
|
||||
|
@@ -1,3 +1,4 @@
|
||||
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
@@ -7,10 +8,11 @@
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -23,7 +25,7 @@
|
||||
// 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
|
||||
// * The name of the copyright holders 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
|
||||
@@ -39,5 +41,9 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/core.hpp"
|
||||
#import "opencv2/highgui/cap_ios.h"
|
||||
|
||||
UIImage* MatToUIImage(const cv::Mat& image);
|
||||
void UIImageToMat(const UIImage* image,
|
||||
cv::Mat& m, bool alphaExist = false);
|
@@ -11,11 +11,21 @@ using std::tr1::get;
|
||||
|
||||
typedef perf::TestBaseWithParam<std::string> VideoCapture_Reading;
|
||||
|
||||
#if defined(HAVE_MSMF)
|
||||
// MPEG2 is not supported by Media Foundation yet
|
||||
// http://social.msdn.microsoft.com/Forums/en-US/mediafoundationdevelopment/thread/39a36231-8c01-40af-9af5-3c105d684429
|
||||
PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi",
|
||||
"highgui/video/big_buck_bunny.mov",
|
||||
"highgui/video/big_buck_bunny.mp4",
|
||||
"highgui/video/big_buck_bunny.wmv" ) )
|
||||
|
||||
#else
|
||||
PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi",
|
||||
"highgui/video/big_buck_bunny.mov",
|
||||
"highgui/video/big_buck_bunny.mp4",
|
||||
"highgui/video/big_buck_bunny.mpg",
|
||||
"highgui/video/big_buck_bunny.wmv" ) )
|
||||
#endif
|
||||
{
|
||||
string filename = getDataPath(GetParam());
|
||||
|
||||
@@ -27,4 +37,4 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_
|
||||
SANITY_CHECK(dummy);
|
||||
}
|
||||
|
||||
#endif // BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
#endif // BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
@@ -22,13 +22,19 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame,
|
||||
{
|
||||
string filename = getDataPath(get<0>(GetParam()));
|
||||
bool isColor = get<1>(GetParam());
|
||||
Mat image = imread(filename, 1);
|
||||
#if defined(HAVE_MSMF) && !defined(HAVE_VFW) && !defined(HAVE_FFMPEG) // VFW has greater priority
|
||||
VideoWriter writer(cv::tempfile(".wmv"), VideoWriter::fourcc('W', 'M', 'V', '3'),
|
||||
25, cv::Size(image.cols, image.rows), isColor);
|
||||
#else
|
||||
VideoWriter writer(cv::tempfile(".avi"), VideoWriter::fourcc('X', 'V', 'I', 'D'),
|
||||
25, cv::Size(image.cols, image.rows), isColor);
|
||||
#endif
|
||||
|
||||
VideoWriter writer(cv::tempfile(".avi"), VideoWriter::fourcc('X', 'V', 'I', 'D'), 25, cv::Size(640, 480), isColor);
|
||||
|
||||
TEST_CYCLE() { Mat image = imread(filename, 1); writer << image; }
|
||||
TEST_CYCLE() { image = imread(filename, 1); writer << image; }
|
||||
|
||||
bool dummy = writer.isOpened();
|
||||
SANITY_CHECK(dummy);
|
||||
}
|
||||
|
||||
#endif // BUILD_WITH_VIDEO_OUTPUT_SUPPORT
|
||||
#endif // BUILD_WITH_VIDEO_OUTPUT_SUPPORT
|
||||
|
@@ -1 +0,0 @@
|
||||
#include "perf_precomp.hpp"
|
@@ -19,8 +19,10 @@
|
||||
#if defined(HAVE_XINE) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_QTKIT) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF) || \
|
||||
defined(HAVE_VFW)
|
||||
/*defined(HAVE_OPENNI) too specialized */ \
|
||||
|
||||
@@ -32,8 +34,10 @@
|
||||
#if /*defined(HAVE_XINE) || */\
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_QTKIT) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF) || \
|
||||
defined(HAVE_VFW)
|
||||
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
|
||||
#else
|
||||
|
@@ -49,10 +49,10 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
template<> void Ptr<CvCapture>::delete_obj()
|
||||
template<> void DefaultDeleter<CvCapture>::operator ()(CvCapture* obj) const
|
||||
{ cvReleaseCapture(&obj); }
|
||||
|
||||
template<> void Ptr<CvVideoWriter>::delete_obj()
|
||||
template<> void DefaultDeleter<CvVideoWriter>::operator ()(CvVideoWriter* obj) const
|
||||
{ cvReleaseVideoWriter(&obj); }
|
||||
|
||||
}
|
||||
@@ -117,6 +117,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
#ifdef HAVE_DSHOW
|
||||
CV_CAP_DSHOW,
|
||||
#endif
|
||||
#ifdef HAVE_MSMF
|
||||
CV_CAP_MSMF,
|
||||
#endif
|
||||
#if 1
|
||||
CV_CAP_IEEE1394, // identical to CV_CAP_DC1394
|
||||
#endif
|
||||
@@ -132,7 +135,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
#ifdef HAVE_MIL
|
||||
CV_CAP_MIL,
|
||||
#endif
|
||||
#ifdef HAVE_QUICKTIME
|
||||
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
|
||||
CV_CAP_QT,
|
||||
#endif
|
||||
#ifdef HAVE_UNICAP
|
||||
@@ -182,6 +185,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
defined(HAVE_CMU1394) || \
|
||||
defined(HAVE_MIL) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_QTKIT) || \
|
||||
defined(HAVE_UNICAP) || \
|
||||
defined(HAVE_PVAPI) || \
|
||||
defined(HAVE_OPENNI) || \
|
||||
@@ -196,13 +200,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
|
||||
switch (domains[i])
|
||||
{
|
||||
#ifdef HAVE_MSMF
|
||||
case CV_CAP_MSMF:
|
||||
capture = cvCreateCameraCapture_MSMF (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_DSHOW
|
||||
case CV_CAP_DSHOW:
|
||||
capture = cvCreateCameraCapture_DShow (index);
|
||||
@@ -210,7 +207,13 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MSMF
|
||||
case CV_CAP_MSMF:
|
||||
capture = cvCreateCameraCapture_MSMF (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_TYZX
|
||||
case CV_CAP_STEREO:
|
||||
capture = cvCreateCameraCapture_TYZX (index);
|
||||
@@ -218,14 +221,12 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CV_CAP_VFW:
|
||||
#ifdef HAVE_VFW
|
||||
capture = cvCreateCameraCapture_VFW (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
#endif
|
||||
|
||||
#if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO
|
||||
capture = cvCreateCameraCapture_V4L (index);
|
||||
if (capture)
|
||||
@@ -277,7 +278,7 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QUICKTIME
|
||||
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
|
||||
case CV_CAP_QT:
|
||||
capture = cvCreateCameraCapture_QT (index);
|
||||
if (capture)
|
||||
@@ -359,6 +360,16 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_FFMPEG_proxy (filename);
|
||||
|
||||
#ifdef HAVE_VFW
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_VFW (filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MSMF
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_MSMF (filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XINE
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_XINE (filename);
|
||||
@@ -369,7 +380,7 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
|
||||
result = cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QUICKTIME
|
||||
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_QT (filename);
|
||||
#endif
|
||||
@@ -407,6 +418,16 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color);
|
||||
|
||||
#ifdef HAVE_VFW
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MSMF
|
||||
if (!result)
|
||||
result = cvCreateVideoWriter_MSMF(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
/* #ifdef HAVE_XINE
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
|
||||
@@ -417,7 +438,7 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
result = cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QUICKTIME
|
||||
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
@@ -470,15 +491,15 @@ VideoCapture::~VideoCapture()
|
||||
|
||||
bool VideoCapture::open(const String& filename)
|
||||
{
|
||||
if (!isOpened())
|
||||
cap = cvCreateFileCapture(filename.c_str());
|
||||
if (isOpened()) release();
|
||||
cap.reset(cvCreateFileCapture(filename.c_str()));
|
||||
return isOpened();
|
||||
}
|
||||
|
||||
bool VideoCapture::open(int device)
|
||||
{
|
||||
if (!isOpened())
|
||||
cap = cvCreateCameraCapture(device);
|
||||
if (isOpened()) release();
|
||||
cap.reset(cvCreateCameraCapture(device));
|
||||
return isOpened();
|
||||
}
|
||||
|
||||
@@ -557,7 +578,7 @@ VideoWriter::~VideoWriter()
|
||||
|
||||
bool VideoWriter::open(const String& filename, int _fourcc, double fps, Size frameSize, bool isColor)
|
||||
{
|
||||
writer = cvCreateVideoWriter(filename.c_str(), _fourcc, fps, frameSize, isColor);
|
||||
writer.reset(cvCreateVideoWriter(filename.c_str(), _fourcc, fps, frameSize, isColor));
|
||||
return isOpened();
|
||||
}
|
||||
|
||||
|
@@ -1325,4 +1325,3 @@ bool CvVideoWriter_AVFoundation::writeFrame(const IplImage* iplimage) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -304,6 +304,11 @@ bool CvCaptureCAM_DC1394_v2_CPP::startCapture()
|
||||
return false;
|
||||
if (isoSpeed > 0)
|
||||
{
|
||||
// if capable set operation mode to 1394b for iso speeds above 400
|
||||
if (isoSpeed > 400 && dcCam->bmode_capable == DC1394_TRUE)
|
||||
{
|
||||
dc1394_video_set_operation_mode(dcCam, DC1394_OPERATION_MODE_1394B);
|
||||
}
|
||||
code = dc1394_video_set_iso_speed(dcCam,
|
||||
isoSpeed <= 100 ? DC1394_ISO_SPEED_100 :
|
||||
isoSpeed <= 200 ? DC1394_ISO_SPEED_200 :
|
||||
|
@@ -3162,18 +3162,18 @@ void CvCaptureCAM_DShow::close()
|
||||
// Initialize camera input
|
||||
bool CvCaptureCAM_DShow::open( int _index )
|
||||
{
|
||||
int try_index = _index;
|
||||
int devices = 0;
|
||||
|
||||
close();
|
||||
devices = VI.listDevices(true);
|
||||
if (devices == 0)
|
||||
return false;
|
||||
try_index = try_index < 0 ? 0 : (try_index > devices-1 ? devices-1 : try_index);
|
||||
VI.setupDevice(try_index);
|
||||
if( !VI.isDeviceSetup(try_index) )
|
||||
if (_index < 0 || _index > devices-1)
|
||||
return false;
|
||||
index = try_index;
|
||||
VI.setupDevice(_index);
|
||||
if( !VI.isDeviceSetup(_index) )
|
||||
return false;
|
||||
index = _index;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -85,6 +85,16 @@ private:
|
||||
icvInitFFMPEG()
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
# ifdef HAVE_WINRT
|
||||
const wchar_t* module_name = L"opencv_ffmpeg"
|
||||
CVAUX_STRW(CV_MAJOR_VERSION) CVAUX_STRW(CV_MINOR_VERSION) CVAUX_STRW(CV_SUBMINOR_VERSION)
|
||||
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
|
||||
L"_64"
|
||||
#endif
|
||||
L".dll";
|
||||
|
||||
icvFFOpenCV = LoadPackagedLibrary( module_name, 0 );
|
||||
# else
|
||||
const char* module_name = "opencv_ffmpeg"
|
||||
CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
|
||||
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
|
||||
@@ -93,6 +103,8 @@ private:
|
||||
".dll";
|
||||
|
||||
icvFFOpenCV = LoadLibrary( module_name );
|
||||
# endif
|
||||
|
||||
if( icvFFOpenCV )
|
||||
{
|
||||
icvCreateFileCapture_FFMPEG_p =
|
||||
@@ -209,11 +221,7 @@ CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename)
|
||||
if( result->open( filename ))
|
||||
return result;
|
||||
delete result;
|
||||
#ifdef HAVE_VFW
|
||||
return cvCreateFileCapture_VFW(filename);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
class CvVideoWriter_FFMPEG_proxy :
|
||||
@@ -263,9 +271,5 @@ CvVideoWriter* cvCreateVideoWriter_FFMPEG_proxy( const char* filename, int fourc
|
||||
if( result->open( filename, fourcc, fps, frameSize, isColor != 0 ))
|
||||
return result;
|
||||
delete result;
|
||||
#ifdef HAVE_VFW
|
||||
return cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, isColor);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@@ -7,9 +7,11 @@ extern "C"
|
||||
#endif
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#define OPENCV_FFMPEG_API __declspec(dllexport)
|
||||
# define OPENCV_FFMPEG_API __declspec(dllexport)
|
||||
#elif defined __GNUC__ && __GNUC__ >= 4
|
||||
# define OPENCV_FFMPEG_API __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define OPENCV_FFMPEG_API
|
||||
# define OPENCV_FFMPEG_API
|
||||
#endif
|
||||
|
||||
enum
|
||||
@@ -94,4 +96,3 @@ typedef int (*Read_InputMediaStream_FFMPEG_Plugin)(struct InputMediaStream_FFMPE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -374,7 +374,15 @@ private:
|
||||
|
||||
struct ImplMutex::Impl
|
||||
{
|
||||
void init() { InitializeCriticalSection(&cs); refcount = 1; }
|
||||
void init()
|
||||
{
|
||||
#if (_WIN32_WINNT >= 0x0600)
|
||||
::InitializeCriticalSectionEx(&cs, 1000, 0);
|
||||
#else
|
||||
::InitializeCriticalSection(&cs);
|
||||
#endif
|
||||
refcount = 1;
|
||||
}
|
||||
void destroy() { DeleteCriticalSection(&cs); }
|
||||
|
||||
void lock() { EnterCriticalSection(&cs); }
|
||||
@@ -1204,7 +1212,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
|
||||
#if LIBAVUTIL_BUILD > CALC_FFMPEG_VERSION(51,11,0)
|
||||
/* Some settings for libx264 encoding, restore dummy values for gop_size
|
||||
and qmin since they will be set to reasonable defaults by the libx264
|
||||
preset system. Also, use a crf encode with the default quality rating,
|
||||
preset system. Also, use a crf encode with the default quality rating,
|
||||
this seems easier than finding an appropriate default bitrate. */
|
||||
if (c->codec_id == CODEC_ID_H264) {
|
||||
c->gop_size = -1;
|
||||
@@ -1392,8 +1400,6 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int
|
||||
/// close video output stream and free associated memory
|
||||
void CvVideoWriter_FFMPEG::close()
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
// nothing to do if already released
|
||||
if ( !picture )
|
||||
return;
|
||||
@@ -1449,13 +1455,6 @@ void CvVideoWriter_FFMPEG::close()
|
||||
|
||||
av_free(outbuf);
|
||||
|
||||
/* free the streams */
|
||||
for(i = 0; i < oc->nb_streams; i++)
|
||||
{
|
||||
av_freep(&oc->streams[i]->codec);
|
||||
av_freep(&oc->streams[i]);
|
||||
}
|
||||
|
||||
if (!(fmt->flags & AVFMT_NOFILE))
|
||||
{
|
||||
/* close the output file */
|
||||
@@ -1473,7 +1472,7 @@ void CvVideoWriter_FFMPEG::close()
|
||||
}
|
||||
|
||||
/* free the stream */
|
||||
av_free(oc);
|
||||
avformat_free_context(oc);
|
||||
|
||||
if( temp_image.data )
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@
|
||||
* cap_ios_abstract_camera.mm
|
||||
* For iOS video I/O
|
||||
* by Eduard Feicho on 29/07/12
|
||||
* by Alexander Shishkov on 17/07/13
|
||||
* Copyright 2012. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -405,4 +406,88 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)lockFocus;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isFocusModeSupported:AVCaptureFocusModeLocked]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.focusMode = AVCaptureFocusModeLocked;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for locked focus configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) unlockFocus;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.focusMode = AVCaptureFocusModeContinuousAutoFocus;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for autofocus configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)lockExposure;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isExposureModeSupported:AVCaptureExposureModeLocked]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.exposureMode = AVCaptureExposureModeLocked;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for locked exposure configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) unlockExposure;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.exposureMode = AVCaptureExposureModeContinuousAutoExposure;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for autoexposure configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)lockBalance;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeLocked]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.whiteBalanceMode = AVCaptureWhiteBalanceModeLocked;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for locked white balance configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) unlockBalance;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.whiteBalanceMode = AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for auto white balance configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -2,6 +2,7 @@
|
||||
* cap_ios_video_camera.mm
|
||||
* For iOS video I/O
|
||||
* by Eduard Feicho on 29/07/12
|
||||
* by Alexander Shishkov on 17/07/13
|
||||
* Copyright 2012. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,7 +31,6 @@
|
||||
|
||||
#import "opencv2/highgui/cap_ios.h"
|
||||
#include "precomp.hpp"
|
||||
|
||||
#import <AssetsLibrary/AssetsLibrary.h>
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
@synthesize videoDataOutput;
|
||||
|
||||
@synthesize recordVideo;
|
||||
@synthesize rotateVideo;
|
||||
//@synthesize videoFileOutput;
|
||||
@synthesize recordAssetWriterInput;
|
||||
@synthesize recordPixelBufferAdaptor;
|
||||
@@ -85,6 +86,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
if (self) {
|
||||
self.useAVCaptureVideoPreviewLayer = NO;
|
||||
self.recordVideo = NO;
|
||||
self.rotateVideo = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -269,13 +271,8 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma mark - Private Interface
|
||||
|
||||
|
||||
|
||||
- (void)createVideoDataOutput;
|
||||
{
|
||||
// Make a video data output
|
||||
@@ -389,6 +386,38 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
[self.parentView.layer addSublayer:self.customPreviewLayer];
|
||||
}
|
||||
|
||||
- (CVPixelBufferRef) pixelBufferFromCGImage: (CGImageRef) image
|
||||
{
|
||||
|
||||
CGSize frameSize = CGSizeMake(CGImageGetWidth(image), CGImageGetHeight(image));
|
||||
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO], kCVPixelBufferCGImageCompatibilityKey,
|
||||
[NSNumber numberWithBool:NO], kCVPixelBufferCGBitmapContextCompatibilityKey,
|
||||
nil];
|
||||
CVPixelBufferRef pxbuffer = NULL;
|
||||
CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, frameSize.width,
|
||||
frameSize.height, kCVPixelFormatType_32ARGB, (CFDictionaryRef) CFBridgingRetain(options),
|
||||
&pxbuffer);
|
||||
NSParameterAssert(status == kCVReturnSuccess && pxbuffer != NULL);
|
||||
|
||||
CVPixelBufferLockBaseAddress(pxbuffer, 0);
|
||||
void *pxdata = CVPixelBufferGetBaseAddress(pxbuffer);
|
||||
|
||||
|
||||
CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
CGContextRef context = CGBitmapContextCreate(pxdata, frameSize.width,
|
||||
frameSize.height, 8, 4*frameSize.width, rgbColorSpace,
|
||||
kCGImageAlphaPremultipliedFirst);
|
||||
|
||||
CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image),
|
||||
CGImageGetHeight(image)), image);
|
||||
CGColorSpaceRelease(rgbColorSpace);
|
||||
CGContextRelease(context);
|
||||
|
||||
CVPixelBufferUnlockBaseAddress(pxbuffer, 0);
|
||||
|
||||
return pxbuffer;
|
||||
}
|
||||
|
||||
#pragma mark - Protocol AVCaptureVideoDataOutputSampleBufferDelegate
|
||||
|
||||
@@ -522,7 +551,8 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
}
|
||||
|
||||
if (self.recordAssetWriterInput.readyForMoreMediaData) {
|
||||
if (! [self.recordPixelBufferAdaptor appendPixelBuffer:imageBuffer
|
||||
CVImageBufferRef pixelBuffer = [self pixelBufferFromCGImage:dstImage];
|
||||
if (! [self.recordPixelBufferAdaptor appendPixelBuffer:pixelBuffer
|
||||
withPresentationTime:lastSampleTime] ) {
|
||||
NSLog(@"Video Writing Error");
|
||||
}
|
||||
@@ -543,9 +573,12 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
|
||||
- (void)updateOrientation;
|
||||
{
|
||||
NSLog(@"rotate..");
|
||||
self.customPreviewLayer.bounds = CGRectMake(0, 0, self.parentView.frame.size.width, self.parentView.frame.size.height);
|
||||
[self layoutPreviewLayer];
|
||||
if (self.rotateVideo == YES)
|
||||
{
|
||||
NSLog(@"rotate..");
|
||||
self.customPreviewLayer.bounds = CGRectMake(0, 0, self.parentView.frame.size.width, self.parentView.frame.size.height);
|
||||
[self layoutPreviewLayer];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -14,7 +14,9 @@ It has been tested with the motempl sample program
|
||||
First Patch: August 24, 2004 Travis Wood TravisOCV@tkwood.com
|
||||
For Release: OpenCV-Linux Beta4 opencv-0.9.6
|
||||
Tested On: LMLBT44 with 8 video inputs
|
||||
Problems? Post problems/fixes to OpenCV group on groups.yahoo.com
|
||||
Problems? Post your questions at answers.opencv.org,
|
||||
Report bugs at code.opencv.org,
|
||||
Submit your fixes at https://github.com/Itseez/opencv/
|
||||
Patched Comments:
|
||||
|
||||
TW: The cv cam utils that came with the initial release of OpenCV for LINUX Beta4
|
||||
|
@@ -1,32 +1,44 @@
|
||||
/*
|
||||
* CvCapture.mm
|
||||
*
|
||||
* Created by Nicholas Butko on 11/3/09.
|
||||
* Copyright 2009. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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) 2013, 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 the copyright holders 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 contributor 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"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
@@ -399,6 +411,9 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
|
||||
|
||||
void CvCaptureCAM::setWidthHeight() {
|
||||
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[mCaptureSession stopRunning];
|
||||
|
||||
NSDictionary* pixelBufferOptions = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithDouble:1.0*width], (id)kCVPixelBufferWidthKey,
|
||||
[NSNumber numberWithDouble:1.0*height], (id)kCVPixelBufferHeightKey,
|
||||
@@ -407,6 +422,9 @@ void CvCaptureCAM::setWidthHeight() {
|
||||
nil];
|
||||
|
||||
[mCaptureDecompressedVideoOutput setPixelBufferAttributes:pixelBufferOptions];
|
||||
|
||||
[mCaptureSession startRunning];
|
||||
|
||||
grabFrame(60);
|
||||
[localpool drain];
|
||||
}
|
||||
@@ -1026,4 +1044,3 @@ bool CvVideoWriter_QT::writeFrame(const IplImage* image) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,9 @@ It has been tested with the motempl sample program
|
||||
First Patch: August 24, 2004 Travis Wood TravisOCV@tkwood.com
|
||||
For Release: OpenCV-Linux Beta4 opencv-0.9.6
|
||||
Tested On: LMLBT44 with 8 video inputs
|
||||
Problems? Post problems/fixes to OpenCV group on groups.yahoo.com
|
||||
Problems? Post your questions at answers.opencv.org,
|
||||
Report bugs at code.opencv.org,
|
||||
Submit your fixes at https://github.com/Itseez/opencv/
|
||||
Patched Comments:
|
||||
|
||||
TW: The cv cam utils that came with the initial release of OpenCV for LINUX Beta4
|
||||
|
@@ -613,8 +613,10 @@ bool CvVideoWriter_VFW::open( const char* filename, int _fourcc, double _fps, Cv
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -52,6 +52,8 @@ void CvCaptureCAM_XIMEA::init()
|
||||
{
|
||||
xiGetNumberDevices( &numDevices);
|
||||
hmv = NULL;
|
||||
frame = NULL;
|
||||
timeout = 0;
|
||||
memset(&image, 0, sizeof(XI_IMG));
|
||||
}
|
||||
|
||||
@@ -60,6 +62,8 @@ void CvCaptureCAM_XIMEA::init()
|
||||
// Initialize camera input
|
||||
bool CvCaptureCAM_XIMEA::open( int wIndex )
|
||||
{
|
||||
#define HandleXiResult(res) if (res!=XI_OK) goto error;
|
||||
|
||||
int mvret = XI_OK;
|
||||
|
||||
if(numDevices == 0)
|
||||
@@ -73,26 +77,42 @@ bool CvCaptureCAM_XIMEA::open( int wIndex )
|
||||
|
||||
// always use auto exposure/gain
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_AEAG, 1);
|
||||
if(mvret != XI_OK) goto error;
|
||||
|
||||
// always use auto white ballance
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, 1);
|
||||
if(mvret != XI_OK) goto error;
|
||||
|
||||
// default image format RGB24
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24);
|
||||
if(mvret != XI_OK) goto error;
|
||||
HandleXiResult(mvret);
|
||||
|
||||
int width = 0;
|
||||
mvret = xiGetParamInt( hmv, XI_PRM_WIDTH, &width);
|
||||
if(mvret != XI_OK) goto error;
|
||||
HandleXiResult(mvret);
|
||||
|
||||
int height = 0;
|
||||
mvret = xiGetParamInt( hmv, XI_PRM_HEIGHT, &height);
|
||||
if(mvret != XI_OK) goto error;
|
||||
HandleXiResult(mvret);
|
||||
|
||||
// allocate frame buffer for RGB24 image
|
||||
frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 3);
|
||||
int isColor = 0;
|
||||
mvret = xiGetParamInt(hmv, XI_PRM_IMAGE_IS_COLOR, &isColor);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
if(isColor) // for color cameras
|
||||
{
|
||||
// default image format RGB24
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_RGB24);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
// always use auto white ballance for color cameras
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_AUTO_WB, 1);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
// allocate frame buffer for RGB24 image
|
||||
frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 3);
|
||||
}
|
||||
else // for mono cameras
|
||||
{
|
||||
// default image format MONO8
|
||||
mvret = xiSetParamInt( hmv, XI_PRM_IMAGE_DATA_FORMAT, XI_MONO8);
|
||||
HandleXiResult(mvret);
|
||||
|
||||
// allocate frame buffer for MONO8 image
|
||||
frame = cvCreateImage(cvSize( width, height), IPL_DEPTH_8U, 1);
|
||||
}
|
||||
|
||||
//default capture timeout 10s
|
||||
timeout = 10000;
|
||||
@@ -119,8 +139,11 @@ void CvCaptureCAM_XIMEA::close()
|
||||
if(frame)
|
||||
cvReleaseImage(&frame);
|
||||
|
||||
xiStopAcquisition(hmv);
|
||||
xiCloseDevice(hmv);
|
||||
if(hmv)
|
||||
{
|
||||
xiStopAcquisition(hmv);
|
||||
xiCloseDevice(hmv);
|
||||
}
|
||||
hmv = NULL;
|
||||
}
|
||||
|
||||
@@ -153,11 +176,11 @@ IplImage* CvCaptureCAM_XIMEA::retrieveFrame(int)
|
||||
{
|
||||
// update cvImage after format has changed
|
||||
resetCvImage();
|
||||
|
||||
|
||||
// copy pixel data
|
||||
switch( image.frm)
|
||||
{
|
||||
case XI_MONO8 :
|
||||
case XI_MONO8 :
|
||||
case XI_RAW8 : memcpy( frame->imageData, image.bp, image.width*image.height); break;
|
||||
case XI_MONO16 :
|
||||
case XI_RAW16 : memcpy( frame->imageData, image.bp, image.width*image.height*sizeof(WORD)); break;
|
||||
@@ -187,15 +210,15 @@ void CvCaptureCAM_XIMEA::resetCvImage()
|
||||
{
|
||||
case XI_MONO8 :
|
||||
case XI_RAW8 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 1); break;
|
||||
case XI_MONO16 :
|
||||
case XI_MONO16 :
|
||||
case XI_RAW16 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_16U, 1); break;
|
||||
case XI_RGB24 :
|
||||
case XI_RGB24 :
|
||||
case XI_RGB_PLANAR : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 3); break;
|
||||
case XI_RGB32 : frame = cvCreateImage(cvSize( image.width, image.height), IPL_DEPTH_8U, 4); break;
|
||||
default :
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
cvZero(frame);
|
||||
}
|
||||
/**********************************************************************************/
|
||||
@@ -315,9 +338,9 @@ int CvCaptureCAM_XIMEA::getBpp()
|
||||
{
|
||||
case XI_MONO8 :
|
||||
case XI_RAW8 : return 1;
|
||||
case XI_MONO16 :
|
||||
case XI_MONO16 :
|
||||
case XI_RAW16 : return 2;
|
||||
case XI_RGB24 :
|
||||
case XI_RGB24 :
|
||||
case XI_RGB_PLANAR : return 3;
|
||||
case XI_RGB32 : return 4;
|
||||
default :
|
||||
@@ -325,4 +348,4 @@ int CvCaptureCAM_XIMEA::getBpp()
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
/**********************************************************************************/
|
||||
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 3.9 KiB |