parent
fbc2f7b6e6
commit
27adeb0dc7
@ -0,0 +1,151 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup Label="ProjectConfigurations"> |
||||
<ProjectConfiguration Include="Debug|Win32"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|Win32"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Debug|x64"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>x64</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|x64"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>x64</Platform> |
||||
</ProjectConfiguration> |
||||
</ItemGroup> |
||||
<PropertyGroup Label="Globals"> |
||||
<VCProjectVersion>16.0</VCProjectVersion> |
||||
<Keyword>Win32Proj</Keyword> |
||||
<ProjectGuid>{f62b7b71-0349-475c-aeca-5161913bf22e}</ProjectGuid> |
||||
<RootNamespace>OpenCVVideoParser</RootNamespace> |
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |
||||
<ConfigurationType>Application</ConfigurationType> |
||||
<UseDebugLibraries>true</UseDebugLibraries> |
||||
<PlatformToolset>v143</PlatformToolset> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> |
||||
<ConfigurationType>Application</ConfigurationType> |
||||
<UseDebugLibraries>false</UseDebugLibraries> |
||||
<PlatformToolset>v143</PlatformToolset> |
||||
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> |
||||
<ConfigurationType>Application</ConfigurationType> |
||||
<UseDebugLibraries>true</UseDebugLibraries> |
||||
<PlatformToolset>v143</PlatformToolset> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> |
||||
<ConfigurationType>Application</ConfigurationType> |
||||
<UseDebugLibraries>false</UseDebugLibraries> |
||||
<PlatformToolset>v143</PlatformToolset> |
||||
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||
<ImportGroup Label="ExtensionSettings"> |
||||
</ImportGroup> |
||||
<ImportGroup Label="Shared"> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
</ImportGroup> |
||||
<PropertyGroup Label="UserMacros" /> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||
<ClCompile> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<SDLCheck>true</SDLCheck> |
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<ConformanceMode>true</ConformanceMode> |
||||
<AdditionalIncludeDirectories>C:\Users\sigon\Downloads\opencv\build\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation>true</GenerateDebugInformation> |
||||
<AdditionalLibraryDirectories>C:\Users\sigon\Downloads\opencv-4.8.0\opencv-4.8.0\build\bin\Debug;C:\Users\sigon\Downloads\opencv-4.8.0\opencv-4.8.0\build\lib\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
||||
<AdditionalDependencies>opencv_imgcodecs480d.lib;opencv_videoio480d.lib;opencv_video480d.lib;opencv_imgproc480d.lib;opencv_core480d.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies> |
||||
</Link> |
||||
<ProjectReference> |
||||
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs> |
||||
</ProjectReference> |
||||
</ItemDefinitionGroup> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||
<ClCompile> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<ConformanceMode>true</ConformanceMode> |
||||
<AdditionalIncludeDirectories>C:\Users\sigon\Downloads\opencv\build\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
<GenerateDebugInformation>true</GenerateDebugInformation> |
||||
<AdditionalLibraryDirectories>C:\Users\sigon\Downloads\opencv-4.8.0\opencv-4.8.0\build\lib\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||
<ClCompile> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<SDLCheck>true</SDLCheck> |
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<ConformanceMode>true</ConformanceMode> |
||||
<AdditionalIncludeDirectories>C:\Users\sigon\Downloads\opencv\build\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation>true</GenerateDebugInformation> |
||||
<AdditionalLibraryDirectories>C:\Users\sigon\Downloads\opencv-4.8.0\opencv-4.8.0\build\bin\Debug;C:\Users\sigon\Downloads\opencv-4.8.0\opencv-4.8.0\build\lib\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
||||
<AdditionalDependencies>opencv_imgcodecs480d.lib;opencv_videoio480d.lib;opencv_video480d.lib;opencv_imgproc480d.lib;opencv_core480d.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies> |
||||
</Link> |
||||
<ProjectReference> |
||||
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs> |
||||
</ProjectReference> |
||||
</ItemDefinitionGroup> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||
<ClCompile> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<ConformanceMode>true</ConformanceMode> |
||||
<AdditionalIncludeDirectories>C:\Users\sigon\Downloads\opencv\build\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
<GenerateDebugInformation>true</GenerateDebugInformation> |
||||
<AdditionalLibraryDirectories>C:\Users\sigon\Downloads\opencv-4.8.0\opencv-4.8.0\build\lib\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
<ItemGroup> |
||||
<ClCompile Include="main.cpp" /> |
||||
</ItemGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||
<ImportGroup Label="ExtensionTargets"> |
||||
</ImportGroup> |
||||
</Project> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,57 @@ |
||||
#include <opencv2/videoio.hpp> |
||||
#include <opencv2/video.hpp> |
||||
#include <opencv2/imgproc.hpp> |
||||
#include <opencv2/core/types_c.h> |
||||
#include <opencv2/imgcodecs.hpp> |
||||
#include <string> |
||||
#include <vector> |
||||
#include <iostream> |
||||
|
||||
/*
|
||||
This functions opens a video file and extracts the frames and put them into a vector of Mat(its the class for representing an img) |
||||
*/ |
||||
void extract_frames(const std::string &videoFilePath,std::vector<cv::Mat>& frames){ |
||||
|
||||
try{ |
||||
//open the video file
|
||||
cv::VideoCapture cap(videoFilePath); // open the video file
|
||||
if(!cap.isOpened()) // check if we succeeded
|
||||
cv::error(CV_StsError,"Can not open Video file",__FUNCTION__,"C:\\Users\\sigon\\source\\repos\\OpenCVVideoParser\\OpenCVVideoParser\\main.cpp",14); |
||||
|
||||
//cap.get(CV_CAP_PROP_FRAME_COUNT) contains the number of frames in the video;
|
||||
for(int frameNum = 0; frameNum < cap.get(cv::CAP_PROP_FRAME_COUNT);frameNum++) |
||||
{ |
||||
cv::Mat frame; |
||||
cap >> frame; // get the next frame from video
|
||||
frames.push_back(frame); |
||||
} |
||||
} |
||||
catch( cv::Exception& e ){ |
||||
std::cerr << e.msg << std::endl; |
||||
exit(1); |
||||
} |
||||
|
||||
} |
||||
|
||||
/*
|
||||
It saves a vector of frames into jpg images into the outputDir as 1.jpg,2.jpg etc where 1,2 etc represents the frame number |
||||
*/ |
||||
void save_frames(std::vector<cv::Mat>& frames, const std::string& outputDir){ |
||||
std::vector<int> compression_params; |
||||
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); |
||||
compression_params.push_back(100); |
||||
int frameNumber=0; |
||||
for(std::vector<cv::Mat>::iterator frame = frames.begin(); frame != frames.end(); ++frame){ |
||||
std::string filePath = outputDir + std::to_string(static_cast<long long>(frameNumber))+ ".jpg"; |
||||
imwrite(filePath,*frame,compression_params); |
||||
frameNumber++; |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
int main(){ |
||||
std::vector<cv::Mat>frameData; |
||||
extract_frames("C:/Users/sigon/Videos/test.mp4",frameData); |
||||
|
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue