matlab opencv resize rotated by 180

1 次查看(过去 30 天)
hello all mexOpenCV to compile opencv code and use opencv resize , it works good but i recive rotated image by 180 , how i can correct this
also i want input and output will be uint8 and not single here is cpp file
also i need diffrent size at outputs(currenlty it is 227*227)
code::
mexOpenCV ResizeCV.cpp
peppersSmall=ResizeCV(single(peppersBig));
================
#include "opencvmex.hpp"
#define _DO_NOT_EXPORT
#if defined(_DO_NOT_EXPORT)
#define DllExport
#else
#define DllExport __declspec(dllexport)
#endif
///////////////////////////////////////////////////////////////////////////
// Check inputs
///////////////////////////////////////////////////////////////////////////
void checkInputs(int nrhs, const mxArray *prhs[])
{
const mwSize * tdims, *fdims;
// Check number of inputs
if (nrhs != 1)
{
mexErrMsgTxt("Incorrect number of inputs. Function expects 2 inputs.");
}
// Check input dimensions
tdims = mxGetDimensions(prhs[0]);
//fdims = mxGetDimensions(prhs[1]);
if (mxGetNumberOfDimensions(prhs[0])>2)
{
mexErrMsgTxt("Incorrect number of dimensions. First input must be a matrix.");
}
}
///////////////////////////////////////////////////////////////////////////
// Main entry point to a MEX function
///////////////////////////////////////////////////////////////////////////
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
// Check inputs to mex function
checkInputs(nrhs, prhs);
// Convert mxArray inputs into OpenCV types
cv::Ptr<cv::Mat> imgCV = ocvMxArrayToImage_single(prhs[0], true);
// Allocate output matrix
int outRows = 227;
int outCols = 227;
cv::Mat outCV;
// Run the OpenCV template matching routine
cv::resize(*imgCV,outCV, cv::Size(227,227) ,0,0, cv::INTER_CUBIC );
// Put the data back into the output MATLAB array
plhs[0] = ocvMxArrayFromImage_single(outCV);
}

回答(0 个)

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by