Add FrameCrop code

This commit is contained in:
2015-03-26 01:13:27 +00:00
parent cddf54d3e8
commit 8353c7bddd
2 changed files with 138 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file FrameCrop.cpp
* \brief Crop a region of an image
*/
#include "FrameCrop.h"
namespace plaYUVer
{
FrameCrop::FrameCrop()
{
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE;
m_pchModuleCategory = "Utilities";
m_pchModuleName = "FrameCrop";
m_pchModuleTooltip = "Crop a region of a frame";
m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME;
m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS;
m_cModuleOptions.addOptions()/**/
( "xPosition", m_uiXPosition, "X cordinate of the left-top corner of the crop region [0]" )/**/
( "yPosition", m_uiYPosition, "Y cordinate of the left-top corner of the crop region [0]" )/**/
( "width", m_iXSize, "Width of the crop region [-1]" )/**/
( "height", m_iYSize, "Height of the crop region [-1]" );
m_pcCropedFrame = NULL;
m_uiXPosition = 0;
m_uiYPosition = 0;
m_iXSize = -1;
m_iYSize = -1;
}
Void FrameCrop::create( PlaYUVerFrame* frame )
{
m_pcCropedFrame = NULL;
if( m_iXSize == -1 )
{
m_iXSize = frame->getWidth() - m_uiXPosition;
}
if( m_iYSize == -1 )
{
m_iYSize = frame->getHeight() - m_uiYPosition;
}
m_pcCropedFrame = new PlaYUVerFrame( m_iXSize, m_iYSize, frame->getPelFormat() );
}
PlaYUVerFrame* FrameCrop::process( PlaYUVerFrame* frame )
{
m_pcCropedFrame->copyFrom( frame, m_uiXPosition, m_uiYPosition );
return m_pcCropedFrame;
}
Void FrameCrop::destroy()
{
if( m_pcCropedFrame )
delete m_pcCropedFrame;
m_pcCropedFrame = NULL;
}
} // NAMESPACE
+57
View File
@@ -0,0 +1,57 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file FrameCrop.h
* \brief Crop a region of an image
*/
#ifndef __FRAMECROP_H__
#define __FRAMECROP_H__
#include "PlaYUVerModuleIf.h"
namespace plaYUVer
{
class FrameCrop: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( FrameCrop )
private:
PlaYUVerFrame* m_pcCropedFrame;
UInt m_uiXPosition;
UInt m_uiYPosition;
Int m_iXSize;
Int m_iYSize;
public:
FrameCrop();
virtual ~FrameCrop()
{
}
Void create( PlaYUVerFrame* );
PlaYUVerFrame* process( PlaYUVerFrame* );
Void destroy();
};
} // NAMESPACE
#endif // __FRAMECROP_H__