mirror of
https://github.com/opencv/opencv.git
synced 2026-09-13 05:42:51 -05:00
refactored cuda error handling; remove optional dependancies in soft cascade training app
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
set(name sft)
|
set(name sft)
|
||||||
set(the_target opencv_${name})
|
set(the_target opencv_${name})
|
||||||
|
|
||||||
set(OPENCV_${the_target}_DEPS opencv_core opencv_softcascade opencv_highgui opencv_imgproc opencv_ml OPTIONAL opencv_gpu opencv_objdetect opencv_featurest2d)
|
set(OPENCV_${the_target}_DEPS opencv_core opencv_softcascade opencv_highgui opencv_imgproc opencv_ml)
|
||||||
ocv_check_dependencies(${OPENCV_${the_target}_DEPS})
|
ocv_check_dependencies(${OPENCV_${the_target}_DEPS})
|
||||||
|
|
||||||
if(NOT OCV_DEPENDENCIES_FOUND)
|
if(NOT OCV_DEPENDENCIES_FOUND)
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ def process_module(module, path):
|
|||||||
if module == "gpu":
|
if module == "gpu":
|
||||||
hdrlist.append(os.path.join(path, "..", "core", "include", "opencv2", "core", "cuda_devptrs.hpp"))
|
hdrlist.append(os.path.join(path, "..", "core", "include", "opencv2", "core", "cuda_devptrs.hpp"))
|
||||||
hdrlist.append(os.path.join(path, "..", "core", "include", "opencv2", "core", "gpumat.hpp"))
|
hdrlist.append(os.path.join(path, "..", "core", "include", "opencv2", "core", "gpumat.hpp"))
|
||||||
|
hdrlist.append(os.path.join(path, "..", "core", "include", "opencv2", "core", "stream_accessor.hpp"))
|
||||||
|
|
||||||
decls = []
|
decls = []
|
||||||
for hname in hdrlist:
|
for hname in hdrlist:
|
||||||
|
|||||||
@@ -40,8 +40,8 @@
|
|||||||
//
|
//
|
||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#ifndef __OPENCV_GPU_STREAM_ACCESSOR_HPP__
|
#ifndef __OPENCV_CUDA_STREAM_ACCESSOR_HPP__
|
||||||
#define __OPENCV_GPU_STREAM_ACCESSOR_HPP__
|
#define __OPENCV_CUDA_STREAM_ACCESSOR_HPP__
|
||||||
|
|
||||||
#include "opencv2/core/gpumat.hpp"
|
#include "opencv2/core/gpumat.hpp"
|
||||||
#include "cuda_runtime_api.h"
|
#include "cuda_runtime_api.h"
|
||||||
@@ -61,4 +61,4 @@ namespace cv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __OPENCV_GPU_STREAM_ACCESSOR_HPP__ */
|
#endif /* __OPENCV_CUDA_STREAM_ACCESSOR_HPP__ */
|
||||||
@@ -74,33 +74,6 @@ void cv::gpu::Stream::release() { throw_nogpu(); }
|
|||||||
|
|
||||||
#include "opencv2/core/stream_accessor.hpp"
|
#include "opencv2/core/stream_accessor.hpp"
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
|
||||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
|
|
||||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
|
||||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
|
||||||
{
|
|
||||||
if (cudaSuccess != err)
|
|
||||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void ___nppSafeCall(int err, const char *file, const int line, const char *func = "")
|
|
||||||
{
|
|
||||||
if (err < 0)
|
|
||||||
{
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "NPP API Call Error: " << err;
|
|
||||||
cv::gpu::error(msg.str().c_str(), file, line, func);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace cv { namespace gpu
|
namespace cv { namespace gpu
|
||||||
{
|
{
|
||||||
void copyWithMask(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t stream);
|
void copyWithMask(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t stream);
|
||||||
|
|||||||
@@ -72,19 +72,11 @@ using namespace cv::gpu;
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
|
||||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
|
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
|
||||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__)
|
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
|
||||||
{
|
|
||||||
if (cudaSuccess != err)
|
|
||||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void ___nppSafeCall(int err, const char *file, const int line, const char *func = "")
|
inline void ___nppSafeCall(int err, const char *file, const int line, const char *func = "")
|
||||||
{
|
{
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
|||||||
@@ -190,33 +190,6 @@ void cv::gpu::CudaMem::release() { CV_Error(CV_GpuNotSupported, "The library is
|
|||||||
GpuMat cv::gpu::CudaMem::createGpuMatHeader () const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); return GpuMat(); }
|
GpuMat cv::gpu::CudaMem::createGpuMatHeader () const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); return GpuMat(); }
|
||||||
|
|
||||||
#else /* !defined (HAVE_CUDA) */
|
#else /* !defined (HAVE_CUDA) */
|
||||||
#include <cuda_runtime_api.h>
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
|
||||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
|
|
||||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
|
||||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
|
||||||
{
|
|
||||||
if (cudaSuccess != err)
|
|
||||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void ___nppSafeCall(int err, const char *file, const int line, const char *func = "")
|
|
||||||
{
|
|
||||||
if (err < 0)
|
|
||||||
{
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "NPP API Call Error: " << err;
|
|
||||||
cv::gpu::error(msg.str().c_str(), file, line, func);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cv::gpu::registerPageLocked(Mat& m)
|
void cv::gpu::registerPageLocked(Mat& m)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,18 +67,6 @@ namespace
|
|||||||
void throw_nocuda() { CV_Error(CV_GpuNotSupported, "The library is compiled without GPU support"); }
|
void throw_nocuda() { CV_Error(CV_GpuNotSupported, "The library is compiled without GPU support"); }
|
||||||
#else
|
#else
|
||||||
void throw_nocuda() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); }
|
void throw_nocuda() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); }
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
|
||||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ___cudaSafeCall(cudaError_t err, const char* file, const int line, const char* func = "")
|
|
||||||
{
|
|
||||||
if (cudaSuccess != err)
|
|
||||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,25 @@
|
|||||||
#define GET_OPTIMIZED(func) (func)
|
#define GET_OPTIMIZED(func) (func)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
# include <cuda_runtime_api.h>
|
||||||
|
# include "opencv2/core/gpumat.hpp"
|
||||||
|
|
||||||
|
# if defined(__GNUC__)
|
||||||
|
# define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||||
|
# else
|
||||||
|
# define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
static inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
||||||
|
{
|
||||||
|
if (cudaSuccess != err) cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
# define cudaSafeCall(expr)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,12 @@
|
|||||||
// copy or use the software.
|
// copy or use the software.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// License Agreement
|
// License Agreement
|
||||||
// For Open Source Computer Vision Library
|
// For Open Source Computer Vision Library
|
||||||
//
|
//
|
||||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||||
// Third party copyrights are property of their respective owners.
|
// Third party copyrights are property of their respective owners.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
//
|
//
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other GpuMaterials provided with the distribution.
|
// and/or other materials provided with the distribution.
|
||||||
//
|
//
|
||||||
// * The name of the copyright holders may not be used to endorse or promote products
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
// derived from this software without specific prior written permission.
|
// derived from this software without specific prior written permission.
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
|
||||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other GpuMaterials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of the copyright holders may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
#ifndef __OPENCV_GPU_STREAM_ACCESSOR_HPP__
|
|
||||||
#define __OPENCV_GPU_STREAM_ACCESSOR_HPP__
|
|
||||||
|
|
||||||
#include "opencv2/gpu.hpp"
|
|
||||||
#include "cuda_runtime_api.h"
|
|
||||||
|
|
||||||
namespace cv
|
|
||||||
{
|
|
||||||
namespace gpu
|
|
||||||
{
|
|
||||||
// This is only header file that depends on Cuda. All other headers are independent.
|
|
||||||
// So if you use OpenCV binaries you do noot need to install Cuda Toolkit.
|
|
||||||
// But of you wanna use GPU by yourself, may get cuda stream instance using the class below.
|
|
||||||
// In this case you have to install Cuda Toolkit.
|
|
||||||
struct StreamAccessor
|
|
||||||
{
|
|
||||||
CV_EXPORTS static cudaStream_t getStream(const cv::gpu::Stream& stream);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __OPENCV_GPU_STREAM_ACCESSOR_HPP__ */
|
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "internal_shared.hpp"
|
#include "internal_shared.hpp"
|
||||||
#include "opencv2/gpu/stream_accessor.hpp"
|
#include "opencv2/core/stream_accessor.hpp"
|
||||||
|
|
||||||
#include "nvidia/core/NCV.hpp"
|
#include "nvidia/core/NCV.hpp"
|
||||||
#include "nvidia/NPP_staging/NPP_staging.hpp"
|
#include "nvidia/NPP_staging/NPP_staging.hpp"
|
||||||
|
|||||||
@@ -44,18 +44,18 @@
|
|||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace
|
namespace cv { namespace softcascade { namespace internal {
|
||||||
{
|
void error(const char *error_string, const char *file, const int line, const char *func);
|
||||||
|
}}}
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
||||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
static inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
||||||
{
|
{
|
||||||
// if (cudaSuccess != err) cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
if (cudaSuccess != err) cv::softcascade::internal::error(cudaGetErrorString(err), file, line, func);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CV_PI
|
#ifndef CV_PI
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "opencv2/imgproc.hpp"
|
#include <opencv2/imgproc.hpp>
|
||||||
#include "opencv2/objdetect.hpp"
|
#include <opencv2/objdetect.hpp>
|
||||||
#include "opencv2/highgui.hpp"
|
#include <opencv2/highgui.hpp>
|
||||||
#include <opencv2/softcascade.hpp>
|
#include <opencv2/softcascade.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|||||||
Reference in New Issue
Block a user