replaced macros with template func
This commit is contained in:
parent
f0197006e0
commit
af806bc816
@ -296,4 +296,8 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
// main func
|
// main func
|
||||||
ENTRY_POINT(D3D10WinApp, "D3D10 interop sample");
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
std::string title = "D3D10 interop sample";
|
||||||
|
return d3d_app<D3D10WinApp>(argc, argv, title);
|
||||||
|
}
|
||||||
|
@ -302,4 +302,8 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
// main func
|
// main func
|
||||||
ENTRY_POINT(D3D11WinApp, "D3D11 interop sample");
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
std::string title = "D3D11 interop sample";
|
||||||
|
return d3d_app<D3D11WinApp>(argc, argv, title);
|
||||||
|
}
|
||||||
|
@ -294,4 +294,8 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
// main func
|
// main func
|
||||||
ENTRY_POINT(D3D9WinApp, "D3D9 interop sample");
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
std::string title = "D3D9 interop sample";
|
||||||
|
return d3d_app<D3D9WinApp>(argc, argv, title);
|
||||||
|
}
|
||||||
|
@ -295,4 +295,8 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
// main func
|
// main func
|
||||||
ENTRY_POINT(D3D9ExWinApp, "D3D9Ex interop sample");
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
std::string title = "D3D9Ex interop sample";
|
||||||
|
return d3d_app<D3D9ExWinApp>(argc, argv, title);
|
||||||
|
}
|
||||||
|
@ -113,73 +113,74 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define ENTRY_POINT(type, title) \
|
static void help()
|
||||||
static void help() \
|
{
|
||||||
{ \
|
printf(
|
||||||
printf( \
|
"\nSample demonstrating interoperability of DirectX and OpenCL with OpenCV.\n"
|
||||||
"\nSample demonstrating interoperability of DirectX and OpenCL with OpenCV.\n" \
|
"Hot keys: \n"
|
||||||
"Hot keys: \n" \
|
" 0 - no processing\n"
|
||||||
" 0 - no processing\n" \
|
" 1 - blur DX surface on CPU through OpenCV\n"
|
||||||
" 1 - blur DX surface on CPU through OpenCV\n" \
|
" 2 - blur DX surface on GPU through OpenCV using OpenCL\n"
|
||||||
" 2 - blur DX surface on GPU through OpenCV using OpenCL\n" \
|
" ESC - exit\n\n");
|
||||||
" ESC - exit\n\n"); \
|
}
|
||||||
} \
|
|
||||||
\
|
|
||||||
static const char* keys = \
|
static const char* keys =
|
||||||
{ \
|
{
|
||||||
"{c camera | true | use camera or not}" \
|
"{c camera | true | use camera or not}"
|
||||||
"{f file | | movie file name }" \
|
"{f file | | movie file name }"
|
||||||
"{h help | false | print help info }" \
|
"{h help | false | print help info }"
|
||||||
}; \
|
};
|
||||||
\
|
|
||||||
\
|
|
||||||
int main(int argc, char** argv) \
|
template <typename TApp>
|
||||||
{ \
|
int d3d_app(int argc, char** argv, std::string& title)
|
||||||
|
{
|
||||||
cv::CommandLineParser parser(argc, argv, keys); \
|
cv::CommandLineParser parser(argc, argv, keys); \
|
||||||
bool useCamera = parser.has("camera"); \
|
bool useCamera = parser.has("camera"); \
|
||||||
string file = parser.get<string>("file"); \
|
string file = parser.get<string>("file"); \
|
||||||
bool showHelp = parser.get<bool>("help"); \
|
bool showHelp = parser.get<bool>("help"); \
|
||||||
\
|
|
||||||
if (showHelp) \
|
if (showHelp)
|
||||||
help(); \
|
help();
|
||||||
\
|
|
||||||
parser.printMessage(); \
|
parser.printMessage();
|
||||||
\
|
|
||||||
cv::VideoCapture cap; \
|
cv::VideoCapture cap;
|
||||||
\
|
|
||||||
if (useCamera) \
|
if (useCamera)
|
||||||
cap.open(0); \
|
cap.open(0);
|
||||||
else \
|
else
|
||||||
cap.open(file.c_str()); \
|
cap.open(file.c_str());
|
||||||
\
|
|
||||||
if (!cap.isOpened()) \
|
if (!cap.isOpened())
|
||||||
{ \
|
{
|
||||||
printf("can not open camera or video file\n"); \
|
printf("can not open camera or video file\n");
|
||||||
return -1; \
|
return -1;
|
||||||
} \
|
}
|
||||||
\
|
|
||||||
int width = (int)cap.get(CAP_PROP_FRAME_WIDTH); \
|
int width = (int)cap.get(CAP_PROP_FRAME_WIDTH);
|
||||||
int height = (int)cap.get(CAP_PROP_FRAME_HEIGHT); \
|
int height = (int)cap.get(CAP_PROP_FRAME_HEIGHT);
|
||||||
\
|
|
||||||
std::string wndname = title; \
|
std::string wndname = title;
|
||||||
\
|
|
||||||
type app(width, height, wndname, cap); \
|
TApp app(width, height, wndname, cap);
|
||||||
\
|
|
||||||
try \
|
try
|
||||||
{ \
|
{
|
||||||
app.create(); \
|
app.create();
|
||||||
return app.run(); \
|
return app.run();
|
||||||
} \
|
}
|
||||||
\
|
|
||||||
catch (cv::Exception& e) \
|
catch (cv::Exception& e)
|
||||||
{ \
|
{
|
||||||
std::cerr << "Exception: " << e.what() << std::endl; \
|
std::cerr << "Exception: " << e.what() << std::endl;
|
||||||
return 10; \
|
return 10;
|
||||||
} \
|
}
|
||||||
\
|
|
||||||
catch (...) \
|
catch (...)
|
||||||
{ \
|
{
|
||||||
std::cerr << "FATAL ERROR: Unknown exception" << std::endl; \
|
std::cerr << "FATAL ERROR: Unknown exception" << std::endl;
|
||||||
return 11; \
|
return 11;
|
||||||
} \
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user