From 08cc0afc797d2225cf23fbc785e6a28cc8667285 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Wed, 28 Mar 2018 21:52:00 -0600 Subject: Nuget packaged up dependencies --- redist/minimal_opencv.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 3 deletions(-) (limited to 'redist/minimal_opencv.c') diff --git a/redist/minimal_opencv.c b/redist/minimal_opencv.c index 50eb7df..e35e31d 100644 --- a/redist/minimal_opencv.c +++ b/redist/minimal_opencv.c @@ -1,5 +1,3 @@ -//#include "/home/justin/source/CLAPACK/INCLUDE/f2c.h" -//#include "/home/justin/source/CLAPACK/INCLUDE/clapack.h" #include #include @@ -10,8 +8,176 @@ #include "string.h" #include +#include + //#define DEBUG_PRINT +#ifdef _WIN3211 +#include "cblas.h" + +int CBLAS_CallFromC; +int RowMajorStrg; +void cblas_xerbla(int info, const char *rout, const char *form, ...) +{ + extern int RowMajorStrg; + char empty[1] = ""; + va_list argptr; + + va_start(argptr, form); + + if (RowMajorStrg) + { + if (strstr(rout, "gemm") != 0) + { + if (info == 5) info = 4; + else if (info == 4) info = 5; + else if (info == 11) info = 9; + else if (info == 9) info = 11; + } + else if (strstr(rout, "symm") != 0 || strstr(rout, "hemm") != 0) + { + if (info == 5) info = 4; + else if (info == 4) info = 5; + } + else if (strstr(rout, "trmm") != 0 || strstr(rout, "trsm") != 0) + { + if (info == 7) info = 6; + else if (info == 6) info = 7; + } + else if (strstr(rout, "gemv") != 0) + { + if (info == 4) info = 3; + else if (info == 3) info = 4; + } + else if (strstr(rout, "gbmv") != 0) + { + if (info == 4) info = 3; + else if (info == 3) info = 4; + else if (info == 6) info = 5; + else if (info == 5) info = 6; + } + else if (strstr(rout, "ger") != 0) + { + if (info == 3) info = 2; + else if (info == 2) info = 3; + else if (info == 8) info = 6; + else if (info == 6) info = 8; + } + else if ((strstr(rout, "her2") != 0 || strstr(rout, "hpr2") != 0) + && strstr(rout, "her2k") == 0) + { + if (info == 8) info = 6; + else if (info == 6) info = 8; + } + } + if (info) + fprintf(stderr, "Parameter %d to routine %s was incorrect\n", info, rout); + vfprintf(stderr, form, argptr); + va_end(argptr); + if (info && !info) + F77_xerbla(empty, &info); /* Force link of our F77 error handler */ + exit(-1); +} +void cblas_dgemm(const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE TransA, + const CBLAS_TRANSPOSE TransB, const int M, const int N, + const int K, const double alpha, const double *A, + const int lda, const double *B, const int ldb, + const double beta, double *C, const int ldc) +{ + char TA, TB; +#ifdef F77_CHAR + F77_CHAR F77_TA, F77_TB; +#else +#define F77_TA &TA +#define F77_TB &TB +#endif + +#ifdef F77_INT + F77_INT F77_M = M, F77_N = N, F77_K = K, F77_lda = lda, F77_ldb = ldb; + F77_INT F77_ldc = ldc; +#else +#define F77_M M +#define F77_N N +#define F77_K K +#define F77_lda lda +#define F77_ldb ldb +#define F77_ldc ldc +#endif + + RowMajorStrg = 0; + CBLAS_CallFromC = 1; + + if (layout == CblasColMajor) + { + if (TransA == CblasTrans) TA = 'T'; + else if (TransA == CblasConjTrans) TA = 'C'; + else if (TransA == CblasNoTrans) TA = 'N'; + else + { + cblas_xerbla(2, "cblas_dgemm", "Illegal TransA setting, %d\n", TransA); + CBLAS_CallFromC = 0; + RowMajorStrg = 0; + return; + } + + if (TransB == CblasTrans) TB = 'T'; + else if (TransB == CblasConjTrans) TB = 'C'; + else if (TransB == CblasNoTrans) TB = 'N'; + else + { + cblas_xerbla(3, "cblas_dgemm", "Illegal TransB setting, %d\n", TransB); + CBLAS_CallFromC = 0; + RowMajorStrg = 0; + return; + } + +#ifdef F77_CHAR + F77_TA = C2F_CHAR(&TA); + F77_TB = C2F_CHAR(&TB); +#endif + + F77_dgemm(F77_TA, F77_TB, &F77_M, &F77_N, &F77_K, &alpha, A, + &F77_lda, B, &F77_ldb, &beta, C, &F77_ldc); + } + else if (layout == CblasRowMajor) + { + RowMajorStrg = 1; + if (TransA == CblasTrans) TB = 'T'; + else if (TransA == CblasConjTrans) TB = 'C'; + else if (TransA == CblasNoTrans) TB = 'N'; + else + { + cblas_xerbla(2, "cblas_dgemm", "Illegal TransA setting, %d\n", TransA); + CBLAS_CallFromC = 0; + RowMajorStrg = 0; + return; + } + if (TransB == CblasTrans) TA = 'T'; + else if (TransB == CblasConjTrans) TA = 'C'; + else if (TransB == CblasNoTrans) TA = 'N'; + else + { + cblas_xerbla(2, "cblas_dgemm", "Illegal TransB setting, %d\n", TransB); + CBLAS_CallFromC = 0; + RowMajorStrg = 0; + return; + } +#ifdef F77_CHAR + F77_TA = C2F_CHAR(&TA); + F77_TB = C2F_CHAR(&TB); +#endif + + F77_dgemm(F77_TA, F77_TB, &F77_N, &F77_M, &F77_K, &alpha, B, + &F77_ldb, A, &F77_lda, &beta, C, &F77_ldc); + } + else cblas_xerbla(1, "cblas_dgemm", "Illegal layout setting, %d\n", layout); + CBLAS_CallFromC = 0; + RowMajorStrg = 0; + return; +} +#endif + + int cvRound(float f) { return roundf(f); } #define CV_Error(code, msg) assert(0 && msg); // cv::error( code, msg, CV_Func, __FILE__, __LINE__ ) @@ -27,7 +193,7 @@ void cvCopyTo(const CvMat *srcarr, CvMat *dstarr) { void cvGEMM(const CvMat *src1, const CvMat *src2, double alpha, const CvMat *src3, double beta, CvMat *dst, int tABC) { lapack_int rows1 = src1->rows; lapack_int cols1 = src1->cols; - + lapack_int rows2 = src2->rows; lapack_int cols2 = src2->cols; -- cgit v1.2.3 From d366c1dc70487246e1a1948e33d8a998f54a82ae Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Thu, 29 Mar 2018 10:18:56 -0600 Subject: Removed unused code --- redist/minimal_opencv.c | 170 +----------------------------------------------- 1 file changed, 1 insertion(+), 169 deletions(-) (limited to 'redist/minimal_opencv.c') diff --git a/redist/minimal_opencv.c b/redist/minimal_opencv.c index e35e31d..48bd85e 100644 --- a/redist/minimal_opencv.c +++ b/redist/minimal_opencv.c @@ -8,175 +8,7 @@ #include "string.h" #include -#include - -//#define DEBUG_PRINT - -#ifdef _WIN3211 -#include "cblas.h" - -int CBLAS_CallFromC; -int RowMajorStrg; -void cblas_xerbla(int info, const char *rout, const char *form, ...) -{ - extern int RowMajorStrg; - char empty[1] = ""; - va_list argptr; - - va_start(argptr, form); - - if (RowMajorStrg) - { - if (strstr(rout, "gemm") != 0) - { - if (info == 5) info = 4; - else if (info == 4) info = 5; - else if (info == 11) info = 9; - else if (info == 9) info = 11; - } - else if (strstr(rout, "symm") != 0 || strstr(rout, "hemm") != 0) - { - if (info == 5) info = 4; - else if (info == 4) info = 5; - } - else if (strstr(rout, "trmm") != 0 || strstr(rout, "trsm") != 0) - { - if (info == 7) info = 6; - else if (info == 6) info = 7; - } - else if (strstr(rout, "gemv") != 0) - { - if (info == 4) info = 3; - else if (info == 3) info = 4; - } - else if (strstr(rout, "gbmv") != 0) - { - if (info == 4) info = 3; - else if (info == 3) info = 4; - else if (info == 6) info = 5; - else if (info == 5) info = 6; - } - else if (strstr(rout, "ger") != 0) - { - if (info == 3) info = 2; - else if (info == 2) info = 3; - else if (info == 8) info = 6; - else if (info == 6) info = 8; - } - else if ((strstr(rout, "her2") != 0 || strstr(rout, "hpr2") != 0) - && strstr(rout, "her2k") == 0) - { - if (info == 8) info = 6; - else if (info == 6) info = 8; - } - } - if (info) - fprintf(stderr, "Parameter %d to routine %s was incorrect\n", info, rout); - vfprintf(stderr, form, argptr); - va_end(argptr); - if (info && !info) - F77_xerbla(empty, &info); /* Force link of our F77 error handler */ - exit(-1); -} -void cblas_dgemm(const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE TransA, - const CBLAS_TRANSPOSE TransB, const int M, const int N, - const int K, const double alpha, const double *A, - const int lda, const double *B, const int ldb, - const double beta, double *C, const int ldc) -{ - char TA, TB; -#ifdef F77_CHAR - F77_CHAR F77_TA, F77_TB; -#else -#define F77_TA &TA -#define F77_TB &TB -#endif - -#ifdef F77_INT - F77_INT F77_M = M, F77_N = N, F77_K = K, F77_lda = lda, F77_ldb = ldb; - F77_INT F77_ldc = ldc; -#else -#define F77_M M -#define F77_N N -#define F77_K K -#define F77_lda lda -#define F77_ldb ldb -#define F77_ldc ldc -#endif - - RowMajorStrg = 0; - CBLAS_CallFromC = 1; - - if (layout == CblasColMajor) - { - if (TransA == CblasTrans) TA = 'T'; - else if (TransA == CblasConjTrans) TA = 'C'; - else if (TransA == CblasNoTrans) TA = 'N'; - else - { - cblas_xerbla(2, "cblas_dgemm", "Illegal TransA setting, %d\n", TransA); - CBLAS_CallFromC = 0; - RowMajorStrg = 0; - return; - } - - if (TransB == CblasTrans) TB = 'T'; - else if (TransB == CblasConjTrans) TB = 'C'; - else if (TransB == CblasNoTrans) TB = 'N'; - else - { - cblas_xerbla(3, "cblas_dgemm", "Illegal TransB setting, %d\n", TransB); - CBLAS_CallFromC = 0; - RowMajorStrg = 0; - return; - } - -#ifdef F77_CHAR - F77_TA = C2F_CHAR(&TA); - F77_TB = C2F_CHAR(&TB); -#endif - - F77_dgemm(F77_TA, F77_TB, &F77_M, &F77_N, &F77_K, &alpha, A, - &F77_lda, B, &F77_ldb, &beta, C, &F77_ldc); - } - else if (layout == CblasRowMajor) - { - RowMajorStrg = 1; - if (TransA == CblasTrans) TB = 'T'; - else if (TransA == CblasConjTrans) TB = 'C'; - else if (TransA == CblasNoTrans) TB = 'N'; - else - { - cblas_xerbla(2, "cblas_dgemm", "Illegal TransA setting, %d\n", TransA); - CBLAS_CallFromC = 0; - RowMajorStrg = 0; - return; - } - if (TransB == CblasTrans) TA = 'T'; - else if (TransB == CblasConjTrans) TA = 'C'; - else if (TransB == CblasNoTrans) TA = 'N'; - else - { - cblas_xerbla(2, "cblas_dgemm", "Illegal TransB setting, %d\n", TransB); - CBLAS_CallFromC = 0; - RowMajorStrg = 0; - return; - } -#ifdef F77_CHAR - F77_TA = C2F_CHAR(&TA); - F77_TB = C2F_CHAR(&TB); -#endif - - F77_dgemm(F77_TA, F77_TB, &F77_N, &F77_M, &F77_K, &alpha, B, - &F77_ldb, A, &F77_lda, &beta, C, &F77_ldc); - } - else cblas_xerbla(1, "cblas_dgemm", "Illegal layout setting, %d\n", layout); - CBLAS_CallFromC = 0; - RowMajorStrg = 0; - return; -} -#endif - +#include int cvRound(float f) { return roundf(f); } #define CV_Error(code, msg) assert(0 && msg); // cv::error( code, msg, CV_Func, __FILE__, __LINE__ ) -- cgit v1.2.3 From 030ec10de98b40750ed480499d84cf8b7bcd766c Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Fri, 30 Mar 2018 12:00:07 -0600 Subject: Don't export minimal opencv symbols --- redist/minimal_opencv.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'redist/minimal_opencv.c') diff --git a/redist/minimal_opencv.c b/redist/minimal_opencv.c index 48bd85e..371d6f8 100644 --- a/redist/minimal_opencv.c +++ b/redist/minimal_opencv.c @@ -10,7 +10,14 @@ #include #include -int cvRound(float f) { return roundf(f); } + +#ifdef _WIN32 +#define SURVIVE_LOCAL_ONLY +#else +#define SURVIVE_LOCAL_ONLY __attribute__ ((visibility ("hidden"))) +#endif + +SURVIVE_LOCAL_ONLY int cvRound(float f) { return roundf(f); } #define CV_Error(code, msg) assert(0 && msg); // cv::error( code, msg, CV_Func, __FILE__, __LINE__ ) const int DECOMP_SVD = 1; @@ -18,11 +25,11 @@ const int DECOMP_LU = 2; void print_mat(const CvMat *M); -void cvCopyTo(const CvMat *srcarr, CvMat *dstarr) { +SURVIVE_LOCAL_ONLY void cvCopyTo(const CvMat *srcarr, CvMat *dstarr) { memcpy(dstarr->data.db, srcarr->data.db, sizeof(double) * dstarr->rows * dstarr->cols); } -void cvGEMM(const CvMat *src1, const CvMat *src2, double alpha, const CvMat *src3, double beta, CvMat *dst, int tABC) { +SURVIVE_LOCAL_ONLY void cvGEMM(const CvMat *src1, const CvMat *src2, double alpha, const CvMat *src3, double beta, CvMat *dst, int tABC) { lapack_int rows1 = src1->rows; lapack_int cols1 = src1->cols; @@ -46,7 +53,7 @@ void cvGEMM(const CvMat *src1, const CvMat *src2, double alpha, const CvMat *src lda, src2->data.db, ldb, beta, dst->data.db, dst->cols); } -void cvMulTransposed(const CvMat *src, CvMat *dst, int order, const CvMat *delta, double scale) { +SURVIVE_LOCAL_ONLY void cvMulTransposed(const CvMat *src, CvMat *dst, int order, const CvMat *delta, double scale) { lapack_int rows = src->rows; lapack_int cols = src->cols; @@ -65,14 +72,14 @@ void cvMulTransposed(const CvMat *src, CvMat *dst, int order, const CvMat *delta scale, src->data.db, cols, src->data.db, cols, beta, dst->data.db, dstCols); } -void *cvAlloc(size_t size) { return malloc(size); } +SURVIVE_LOCAL_ONLY void *cvAlloc(size_t size) { return malloc(size); } -static void icvCheckHuge(CvMat *arr) { +SURVIVE_LOCAL_ONLY static void icvCheckHuge(CvMat *arr) { if ((int64_t)arr->step * arr->rows > INT_MAX) arr->type &= ~CV_MAT_CONT_FLAG; } -CvMat *cvCreateMatHeader(int rows, int cols, int type) { +SURVIVE_LOCAL_ONLY CvMat *cvCreateMatHeader(int rows, int cols, int type) { type = CV_MAT_TYPE(type); assert(!(rows < 0 || cols < 0)); @@ -104,17 +111,17 @@ CvMat *cvCreateMatHeader(int rows, int cols, int type) { #define CV_DbgAssert assert -static inline void *cvAlignPtr(const void *ptr, int align) { +SURVIVE_LOCAL_ONLY static inline void *cvAlignPtr(const void *ptr, int align) { CV_DbgAssert((align & (align - 1)) == 0); return (void *)(((size_t)ptr + align - 1) & ~(size_t)(align - 1)); } -static inline int cvAlign(int size, int align) { +SURVIVE_LOCAL_ONLY static inline int cvAlign(int size, int align) { CV_DbgAssert((align & (align - 1)) == 0 && size < INT_MAX); return (size + align - 1) & -align; } -void cvCreateData(CvMat *arr) { +SURVIVE_LOCAL_ONLY void cvCreateData(CvMat *arr) { if (CV_IS_MAT_HDR_Z(arr)) { size_t step, total_size; CvMat *mat = (CvMat *)arr; @@ -142,14 +149,14 @@ void cvCreateData(CvMat *arr) { CV_Error(CV_StsBadArg, "unrecognized or unsupported array type"); } -CvMat *cvCreateMat(int height, int width, int type) { +SURVIVE_LOCAL_ONLY CvMat *cvCreateMat(int height, int width, int type) { CvMat *arr = cvCreateMatHeader(height, width, type); cvCreateData(arr); return arr; } -double cvInvert(const CvMat *srcarr, CvMat *dstarr, int method) { +SURVIVE_LOCAL_ONLY double cvInvert(const CvMat *srcarr, CvMat *dstarr, int method) { lapack_int inf; lapack_int rows = srcarr->rows; lapack_int cols = srcarr->cols; @@ -204,13 +211,13 @@ double cvInvert(const CvMat *srcarr, CvMat *dstarr, int method) { return 0; } -CvMat *cvCloneMat(const CvMat *mat) { +SURVIVE_LOCAL_ONLY CvMat *cvCloneMat(const CvMat *mat) { CvMat *rtn = cvCreateMat(mat->rows, mat->cols, mat->type); cvCopyTo(mat, rtn); return rtn; } -int cvSolve(const CvMat *Aarr, const CvMat *xarr, CvMat *Barr, int method) { +SURVIVE_LOCAL_ONLY int cvSolve(const CvMat *Aarr, const CvMat *xarr, CvMat *Barr, int method) { lapack_int inf; lapack_int arows = Aarr->rows; lapack_int acols = Aarr->cols; @@ -286,7 +293,7 @@ int cvSolve(const CvMat *Aarr, const CvMat *xarr, CvMat *Barr, int method) { return 0; } -void cvTranspose(const CvMat *M, CvMat *dst) { +SURVIVE_LOCAL_ONLY void cvTranspose(const CvMat *M, CvMat *dst) { bool inPlace = M == dst || M->data.db == dst->data.db; double *src = M->data.db; @@ -309,7 +316,7 @@ void cvTranspose(const CvMat *M, CvMat *dst) { } } -void cvSVD(CvMat *aarr, CvMat *warr, CvMat *uarr, CvMat *varr, int flags) { +SURVIVE_LOCAL_ONLY void cvSVD(CvMat *aarr, CvMat *warr, CvMat *uarr, CvMat *varr, int flags) { char jobu = 'A'; char jobvt = 'A'; @@ -347,13 +354,13 @@ void cvSVD(CvMat *aarr, CvMat *warr, CvMat *uarr, CvMat *varr, int flags) { } } -void cvSetZero(CvMat *arr) { +SURVIVE_LOCAL_ONLY void cvSetZero(CvMat *arr) { for (int i = 0; i < arr->rows; i++) for (int j = 0; j < arr->cols; j++) arr->data.db[i * arr->cols + j] = 0; } -void cvReleaseMat(CvMat **mat) { +SURVIVE_LOCAL_ONLY void cvReleaseMat(CvMat **mat) { assert(*(*mat)->refcount == 1); free((*mat)->refcount); free(*mat); -- cgit v1.2.3 From 2a5a0bde0fa45f86b1fcfbfd50bb779f25337573 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sun, 1 Apr 2018 07:28:22 -0600 Subject: Fixed warnings about inline static functions being exported --- redist/minimal_opencv.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'redist/minimal_opencv.c') diff --git a/redist/minimal_opencv.c b/redist/minimal_opencv.c index 371d6f8..988dd0f 100644 --- a/redist/minimal_opencv.c +++ b/redist/minimal_opencv.c @@ -10,11 +10,10 @@ #include #include - #ifdef _WIN32 #define SURVIVE_LOCAL_ONLY #else -#define SURVIVE_LOCAL_ONLY __attribute__ ((visibility ("hidden"))) +#define SURVIVE_LOCAL_ONLY __attribute__((visibility("hidden"))) #endif SURVIVE_LOCAL_ONLY int cvRound(float f) { return roundf(f); } @@ -29,10 +28,11 @@ SURVIVE_LOCAL_ONLY void cvCopyTo(const CvMat *srcarr, CvMat *dstarr) { memcpy(dstarr->data.db, srcarr->data.db, sizeof(double) * dstarr->rows * dstarr->cols); } -SURVIVE_LOCAL_ONLY void cvGEMM(const CvMat *src1, const CvMat *src2, double alpha, const CvMat *src3, double beta, CvMat *dst, int tABC) { +SURVIVE_LOCAL_ONLY void cvGEMM(const CvMat *src1, const CvMat *src2, double alpha, const CvMat *src3, double beta, + CvMat *dst, int tABC) { lapack_int rows1 = src1->rows; lapack_int cols1 = src1->cols; - + lapack_int rows2 = src2->rows; lapack_int cols2 = src2->cols; @@ -74,7 +74,7 @@ SURVIVE_LOCAL_ONLY void cvMulTransposed(const CvMat *src, CvMat *dst, int order, SURVIVE_LOCAL_ONLY void *cvAlloc(size_t size) { return malloc(size); } -SURVIVE_LOCAL_ONLY static void icvCheckHuge(CvMat *arr) { +static void icvCheckHuge(CvMat *arr) { if ((int64_t)arr->step * arr->rows > INT_MAX) arr->type &= ~CV_MAT_CONT_FLAG; } @@ -111,12 +111,12 @@ SURVIVE_LOCAL_ONLY CvMat *cvCreateMatHeader(int rows, int cols, int type) { #define CV_DbgAssert assert -SURVIVE_LOCAL_ONLY static inline void *cvAlignPtr(const void *ptr, int align) { +static inline void *cvAlignPtr(const void *ptr, int align) { CV_DbgAssert((align & (align - 1)) == 0); return (void *)(((size_t)ptr + align - 1) & ~(size_t)(align - 1)); } -SURVIVE_LOCAL_ONLY static inline int cvAlign(int size, int align) { +static inline int cvAlign(int size, int align) { CV_DbgAssert((align & (align - 1)) == 0 && size < INT_MAX); return (size + align - 1) & -align; } -- cgit v1.2.3