Browse Source

Added Emgu.CV.VideoStab to Emgu.CV solution.

git-svn-id: https://emgucv.svn.sourceforge.net/svnroot/emgucv/trunk@1774 d7f09016-e345-0410-b530-edf29a71df78
UWP10
canming 13 years ago
parent
commit
ecd90c7714
  1. 1
      CMakeLists.txt
  2. 5
      Emgu.CV.Extern/gpu/videostab_c.h
  3. 10
      Emgu.CV.Test/Class1.cs
  4. 57
      Emgu.CV.VideoStab/CMakeLists.txt
  5. 12
      Emgu.CV.VideoStab/CaptureFrameSource.cs
  6. 6
      Emgu.CV.VideoStab/Emgu.CV.VideoStab.csproj
  7. 19
      Emgu.CV.VideoStab/FrameSource.cs
  8. 17
      Emgu.CV.VideoStab/OnePassStabilizer.cs
  9. 18
      Emgu.CV.VideoStab/TwoPassStabilizer.cs
  10. 6
      Solution/VS2008/Emgu.CV.sln
  11. 6
      Solution/VS2010/Emgu.CV.sln
  12. 5
      miscellaneous/Emgu.CV.html.shfbproj

1
CMakeLists.txt

@ -301,6 +301,7 @@ ADD_SUBDIRECTORY(Emgu.CV.Test)
ADD_SUBDIRECTORY(Emgu.CV.GPU)
ADD_SUBDIRECTORY(Emgu.CV.OCR)
ADD_SUBDIRECTORY(Emgu.CV.Stitching)
ADD_SUBDIRECTORY(Emgu.CV.VideoStab)
ENDIF()
IF (ANDROID)

5
Emgu.CV.Extern/gpu/videostab_c.h

@ -18,7 +18,10 @@ public:
: _capture(capture)
{};
virtual void reset() {};
virtual void reset()
{
cvSetCaptureProperty(_capture, CV_CAP_PROP_POS_FRAMES, 0);
};
virtual cv::Mat nextFrame()
{

10
Emgu.CV.Test/Class1.cs

@ -392,17 +392,25 @@ namespace Emgu.CV.Test
public static void TestTwoPassVideoStabilizer()
{
ImageViewer viewer = new ImageViewer();
using (Capture capture = new Capture())
using (Capture capture = new Capture("tree.avi"))
using (GaussianMotionFilter motionFilter = new GaussianMotionFilter())
//using (Features2D.FastDetector detector = new Features2D.FastDetector(10, true))
//using (Features2D.SURFDetector detector = new Features2D.SURFDetector(500, false))
//using (Features2D.ORBDetector detector = new Features2D.ORBDetector(500))
using (TwoPassStabilizer stabilizer = new TwoPassStabilizer(capture))
{
Stopwatch watch = new Stopwatch();
//stabilizer.SetMotionEstimator(motionEstimator);
Application.Idle += delegate(object sender, EventArgs e)
{
watch.Reset();
watch.Start();
Image<Bgr, byte> frame = stabilizer.NextFrame();
watch.Stop();
if (watch.ElapsedMilliseconds < 200)
{
Thread.Sleep(200 - (int) watch.ElapsedMilliseconds);
}
if (frame != null)
viewer.Image = frame;
};

57
Emgu.CV.VideoStab/CMakeLists.txt

@ -0,0 +1,57 @@
# --------------------------------------------------------
# Copyright (C) 2004-2012 by EMGU. All rights reserved.
# --------------------------------------------------------
IF(EMGU_CV_BUILD OR EMGU_CV_EXAMPLE_BUILD)
PROJECT(Emgu.CV.VideoStab)
FILE(GLOB_RECURSE SRC_CV_VIDEOSTAB RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cs")
LIST(APPEND SRC_CV_VIDEOSTAB ${CMAKE_CURRENT_SOURCE_DIR}/../CommonAssemblyInfo.cs)
GENERATE_DOCUMENT(${LIBRARY_OUTPUT_PATH}/${PROJECT_NAME})
SIGN_ASSEMBLY(${CMAKE_CURRENT_SOURCE_DIR}/../Emgu.CV.snk)
ADD_CS_REFERENCES("${LIBRARY_OUTPUT_PATH}/Emgu.Util.dll;${LIBRARY_OUTPUT_PATH}/Emgu.CV.dll;${LIBRARY_OUTPUT_PATH}/Emgu.CV.GPU.dll;System.Drawing.dll")
FILE(GLOB RESX_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/*.resx"
"${CMAKE_CURRENT_SOURCE_DIR}/Properties/*.resx")
FOREACH (RESX ${RESX_SRC})
STRING(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "${PROJECT_NAME}." RESOURCES_NAME ${RESX})
STRING(REPLACE ".resx" ".resources" RESOURCES_NAME ${RESOURCES_NAME})
STRING(REPLACE "/" "." RESOURCES_NAME ${RESOURCES_NAME})
ADD_CS_RESOURCES(${RESX} ${RESOURCES_NAME})
ENDFOREACH(RESX)
COMPILE_CS(${PROJECT_NAME} "library" "${SRC_CV_VIDEOSTAB}" ALL)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "emgu")
endif()
ADD_DEPENDENCIES(${PROJECT_NAME} Emgu.CV Emgu.Util Emgu.CV.GPU)
INSTALL(
FILES
${LIBRARY_OUTPUT_PATH}/${PROJECT_NAME}.dll
${LIBRARY_OUTPUT_PATH}/${PROJECT_NAME}.xml
DESTINATION ${CPACK_PACKAGE_CLI_FOLDER}
COMPONENT emgucv_binary)
IF(WIN32 OR APPLE)
INSTALL(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION .
COMPONENT emgucv_source
FILES_MATCHING
PATTERN "*.cs"
PATTERN "*.csproj"
PATTERN "*.resx"
PATTERN ".svn" EXCLUDE
PATTERN "obj" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "${PROJECT_NAME}.dir" EXCLUDE
)
ENDIF()
ENDIF()

12
Emgu.CV.VideoStab/CaptureFrameSource.cs

@ -12,14 +12,24 @@ using Emgu.Util;
namespace Emgu.CV.VideoStab
{
/// <summary>
/// Use the Capture class as a FrameSource
/// </summary>
public class CaptureFrameSource : FrameSource
{
/// <summary>
/// Create a Capture frame source
/// </summary>
/// <param name="capture">The capture object that will be converted to a FrameSource</param>
public CaptureFrameSource(Capture capture)
{
_ptr = VideoStabInvoke.CaptureFrameSourceCreate(capture);
_framSourcePtr = _ptr;
_frameSourcePtr = _ptr;
}
/// <summary>
/// Release the unmanaged memory associated with this CaptureFrameSource
/// </summary>
protected override void DisposeObject()
{
VideoStabInvoke.CaptureFrameSourceRelease(ref _ptr);

6
Emgu.CV.VideoStab/Emgu.CV.VideoStab.csproj

@ -20,18 +20,20 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\bin\Emgu.CV.OCR.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\bin\Emgu.CV.OCR.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />

19
Emgu.CV.VideoStab/FrameSource.cs

@ -12,15 +12,25 @@ using Emgu.Util;
namespace Emgu.CV.VideoStab
{
/// <summary>
/// A FrameSource that can be used by the Video Stabilizer
/// </summary>
public abstract class FrameSource : UnmanagedObject
{
private IntPtr _frameBuffer;
protected IntPtr _framSourcePtr;
/// <summary>
/// The unmanaged pointer the the frameSource
/// </summary>
protected IntPtr _frameSourcePtr;
/// <summary>
/// Retrieve the next frame from the FrameSoure
/// </summary>
/// <returns></returns>
public Image<Bgr, Byte> NextFrame()
{
if (!VideoStabInvoke.FrameSourceGetNextFrame(_framSourcePtr, ref _frameBuffer) || _frameBuffer == IntPtr.Zero)
if (!VideoStabInvoke.FrameSourceGetNextFrame(_frameSourcePtr, ref _frameBuffer) || _frameBuffer == IntPtr.Zero)
return null;
MIplImage iplImage = (MIplImage)Marshal.PtrToStructure(_frameBuffer, typeof(MIplImage));
@ -39,13 +49,16 @@ namespace Emgu.CV.VideoStab
return res;
}
/// <summary>
/// Release the unmanaged memory associated with this FrameSource
/// </summary>
protected override void DisposeObject()
{
if (_frameBuffer != IntPtr.Zero)
{
CvInvoke.cvReleaseImage(ref _frameBuffer);
}
_framSourcePtr = IntPtr.Zero;
_frameSourcePtr = IntPtr.Zero;
}
}
}

17
Emgu.CV.VideoStab/OnePassStabilizer.cs

@ -11,18 +11,30 @@ using Emgu.Util;
namespace Emgu.CV.VideoStab
{
/// <summary>
/// A one pass video stabilizer
/// </summary>
public class OnePassStabilizer : FrameSource
{
private IntPtr _stabilizerBase;
private CaptureFrameSource _captureFrameSource;
/// <summary>
/// Create a one pass stabilizer
/// </summary>
/// <param name="capture">The capture object to be stabalized</param>
public OnePassStabilizer(Capture capture)
{
_captureFrameSource = new CaptureFrameSource(capture);
_ptr = VideoStabInvoke.OnePassStabilizerCreate(_captureFrameSource, ref _stabilizerBase, ref _framSourcePtr);
_ptr = VideoStabInvoke.OnePassStabilizerCreate(_captureFrameSource, ref _stabilizerBase, ref _frameSourcePtr);
}
/// <summary>
/// Set the Motion Filter
/// </summary>
/// <param name="motionFilter">The motion filter</param>
public void SetMotionFilter(GaussianMotionFilter motionFilter)
{
VideoStabInvoke.OnePassStabilizerSetMotionFilter(_ptr, motionFilter);
@ -34,6 +46,9 @@ namespace Emgu.CV.VideoStab
VideoStabInvoke.StabilizerBaseSetMotionEstimator(_stabilizerBase, estimator);
}*/
/// <summary>
/// Release the unmanaged memory associated with the stabilizer
/// </summary>
protected override void DisposeObject()
{
VideoStabInvoke.OnePassStabilizerRelease(ref _ptr);

18
Emgu.CV.VideoStab/TwoPassStabilizer.cs

@ -11,18 +11,34 @@ using Emgu.Util;
namespace Emgu.CV.VideoStab
{
/// <summary>
/// A two pass video stabilizer
/// </summary>
public class TwoPassStabilizer : FrameSource
{
private IntPtr _stabilizerBase;
private CaptureFrameSource _captureFrameSource;
/// <summary>
/// Create a two pass video stabilizer.
/// </summary>
/// <param name="capture">The capture object to be stabilized. Should not be a camera stream.</param>
public TwoPassStabilizer(Capture capture)
{
if (capture.CaptureSource == Capture.CaptureModuleType.Camera)
{
throw new ArgumentException("Two pass stabilizer cannot process camera stream");
}
_captureFrameSource = new CaptureFrameSource(capture);
_ptr = VideoStabInvoke.TwoPassStabilizerCreate(_captureFrameSource, ref _stabilizerBase, ref _framSourcePtr);
_ptr = VideoStabInvoke.TwoPassStabilizerCreate(_captureFrameSource, ref _stabilizerBase, ref _frameSourcePtr);
}
/// <summary>
/// Release the unmanaged memory
/// </summary>
protected override void DisposeObject()
{
VideoStabInvoke.TwoPassStabilizerRelease(ref _ptr);

6
Solution/VS2008/Emgu.CV.sln

@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.OCR", "..\..\Emgu.C
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.Stitching", "..\..\Emgu.CV.Stitching\Emgu.CV.Stitching.csproj", "{D9C9B824-2B7A-48C0-A7D3-484410288CD2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.VideoStab", "..\..\Emgu.CV.VideoStab\Emgu.CV.VideoStab.csproj", "{91A08B78-2FA0-4887-8975-486CE5FC74B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -48,6 +50,10 @@ Global
{D9C9B824-2B7A-48C0-A7D3-484410288CD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9C9B824-2B7A-48C0-A7D3-484410288CD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9C9B824-2B7A-48C0-A7D3-484410288CD2}.Release|Any CPU.Build.0 = Release|Any CPU
{91A08B78-2FA0-4887-8975-486CE5FC74B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91A08B78-2FA0-4887-8975-486CE5FC74B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A08B78-2FA0-4887-8975-486CE5FC74B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A08B78-2FA0-4887-8975-486CE5FC74B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

6
Solution/VS2010/Emgu.CV.sln

@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.OCR", "..\..\Emgu.C
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.Stitching", "..\..\Emgu.CV.Stitching\Emgu.CV.Stitching.csproj", "{D9C9B824-2B7A-48C0-A7D3-484410288CD2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.VideoStab", "..\..\Emgu.CV.VideoStab\Emgu.CV.VideoStab.csproj", "{91A08B78-2FA0-4887-8975-486CE5FC74B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -48,6 +50,10 @@ Global
{D9C9B824-2B7A-48C0-A7D3-484410288CD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9C9B824-2B7A-48C0-A7D3-484410288CD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9C9B824-2B7A-48C0-A7D3-484410288CD2}.Release|Any CPU.Build.0 = Release|Any CPU
{91A08B78-2FA0-4887-8975-486CE5FC74B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91A08B78-2FA0-4887-8975-486CE5FC74B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A08B78-2FA0-4887-8975-486CE5FC74B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A08B78-2FA0-4887-8975-486CE5FC74B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

5
miscellaneous/Emgu.CV.html.shfbproj

@ -43,7 +43,7 @@
<DocumentationSource sourceFile="..\Solution\VS2008\Emgu.CV.sln" />
</DocumentationSources>
<NamespaceSummaries>
<NamespaceSummaryItem name="(global)" isDocumented="True">Emgu CV is a cross platform .Net wrapper for the Intel OpenCV image-processing library. Allows OpenCV functions to be called from .NET compatible languages such as C#, VB, VC++, IronPython. The wrapper can be compiled in Mono and run on Linux, Solaris &amp; Mac OS X.</NamespaceSummaryItem>
<NamespaceSummaryItem name="(global)" isDocumented="True">Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library. Allowing OpenCV functions to be called from .NET compatible languages such as C#, VB, VC++, IronPython etc. The wrapper can be compiled in Mono and run on Windows, Linux, Mac OS X, iPhone, iPad and Android devices.</NamespaceSummaryItem>
<NamespaceSummaryItem name="Emgu" isDocumented="True">Root namespace for class and functions implemented by Emgu</NamespaceSummaryItem>
<NamespaceSummaryItem name="Emgu.CV" isDocumented="True">Wrapper of OpenCV's image processing functions.
Base functions (L1) can be found in CvInvoke class</NamespaceSummaryItem>
@ -69,7 +69,8 @@ Base functions (L1) can be found in CvInvoke class</NamespaceSummaryItem>
<NamespaceSummaryItem name="Emgu.CV.Util" isDocumented="True">A collection of utilities used by Emgu.CV projects</NamespaceSummaryItem>
<NamespaceSummaryItem name="Emgu.CV.OCR" isDocumented="True">Optical character recognition. Wraps the tesseract-ocr engine.</NamespaceSummaryItem>
<NamespaceSummaryItem name="Emgu.CV.Cvb" isDocumented="True">Contains interface for the CvBlob library</NamespaceSummaryItem>
<NamespaceSummaryItem name="Emgu.CV.Stitching" isDocumented="True">Image stitching</NamespaceSummaryItem></NamespaceSummaries>
<NamespaceSummaryItem name="Emgu.CV.Stitching" isDocumented="True">Image stitching</NamespaceSummaryItem>
<NamespaceSummaryItem name="Emgu.CV.VideoStab" isDocumented="True">Video Stabalization</NamespaceSummaryItem></NamespaceSummaries>
<PlugInConfigurations>
</PlugInConfigurations>
</PropertyGroup>

Loading…
Cancel
Save