Fix build of Java API for Windows

This commit is contained in:
Andrey Kamaev 2012-09-15 15:36:37 +04:00
parent fe0d07ae53
commit cd05d9aaad
5 changed files with 33 additions and 19 deletions

View File

@ -187,7 +187,9 @@ set_target_properties(${the_module} PROPERTIES
LINK_INTERFACE_LIBRARIES "" LINK_INTERFACE_LIBRARIES ""
) )
install(TARGETS ${the_module} LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main) install(TARGETS ${the_module}
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
set(lib_target ${the_module}_library) set(lib_target ${the_module}_library)
if(ANDROID) if(ANDROID)

View File

@ -462,8 +462,10 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize
env->SetDoubleArrayRegion(result, 0, 2, fill); env->SetDoubleArrayRegion(result, 0, 2, fill);
if (baseLine != NULL) if (baseLine != NULL) {
env->SetIntArrayRegion(baseLine, 0, 1, pbaseLine); jint jbaseLine = (jint)(*pbaseLine);
env->SetIntArrayRegion(baseLine, 0, 1, &jbaseLine);
}
return result; return result;
@ -872,13 +874,17 @@ public class %(jc)s {
#include "converters.h" #include "converters.h"
#if defined DEBUG && defined ANDROID #if defined DEBUG && defined ANDROID
#include <android/log.h> # include <android/log.h>
#define MODULE_LOG_TAG "OpenCV.%(m)s" # define MODULE_LOG_TAG "OpenCV.%(m)s"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__)) # define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__))
#else //DEBUG #else //DEBUG
#define LOGD(...) # define LOGD(...)
#endif //DEBUG #endif //DEBUG
#ifdef _MSC_VER
# pragma warning(disable:4800 4244)
#endif
#include "opencv2/%(m)s/%(m)s.hpp" #include "opencv2/%(m)s/%(m)s.hpp"
using namespace cv; using namespace cv;

View File

@ -18,6 +18,10 @@
#define LOGD(...) #define LOGD(...)
#endif #endif
#ifdef _MSC_VER
# pragma warning(disable:4800)
#endif
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
using namespace cv; using namespace cv;
@ -2170,7 +2174,7 @@ template<typename T> static int mat_put(cv::Mat* m, int row, int col, int count,
if(! buff) return 0; if(! buff) return 0;
count *= sizeof(T); count *= sizeof(T);
int rest = ((m->rows - row) * m->cols - col) * m->elemSize(); int rest = ((m->rows - row) * m->cols - col) * (int)m->elemSize();
if(count>rest) count = rest; if(count>rest) count = rest;
int res = count; int res = count;
@ -2179,14 +2183,14 @@ template<typename T> static int mat_put(cv::Mat* m, int row, int col, int count,
memcpy(m->ptr(row, col), buff, count); memcpy(m->ptr(row, col), buff, count);
} else { } else {
// row by row // row by row
int num = (m->cols - col) * m->elemSize(); // 1st partial row int num = (m->cols - col) * (int)m->elemSize(); // 1st partial row
if(count<num) num = count; if(count<num) num = count;
uchar* data = m->ptr(row++, col); uchar* data = m->ptr(row++, col);
while(count>0){ while(count>0){
memcpy(data, buff, num); memcpy(data, buff, num);
count -= num; count -= num;
buff += num; buff += num;
num = m->cols * m->elemSize(); num = m->cols * (int)m->elemSize();
if(count<num) num = count; if(count<num) num = count;
data = m->ptr(row++, 0); data = m->ptr(row++, 0);
} }
@ -2330,7 +2334,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char*
if(! buff) return 0; if(! buff) return 0;
int bytesToCopy = count * sizeof(T); int bytesToCopy = count * sizeof(T);
int bytesRestInMat = ((m->rows - row) * m->cols - col) * m->elemSize(); int bytesRestInMat = ((m->rows - row) * m->cols - col) * (int)m->elemSize();
if(bytesToCopy > bytesRestInMat) bytesToCopy = bytesRestInMat; if(bytesToCopy > bytesRestInMat) bytesToCopy = bytesRestInMat;
int res = bytesToCopy; int res = bytesToCopy;
@ -2339,7 +2343,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char*
memcpy(buff, m->ptr(row, col), bytesToCopy); memcpy(buff, m->ptr(row, col), bytesToCopy);
} else { } else {
// row by row // row by row
int bytesInRow = (m->cols - col) * m->elemSize(); // 1st partial row int bytesInRow = (m->cols - col) * (int)m->elemSize(); // 1st partial row
while(bytesToCopy > 0) while(bytesToCopy > 0)
{ {
int len = std::min(bytesToCopy, bytesInRow); int len = std::min(bytesToCopy, bytesInRow);
@ -2348,7 +2352,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char*
buff += len; buff += len;
row++; row++;
col = 0; col = 0;
bytesInRow = m->cols * m->elemSize(); bytesInRow = m->cols * (int)m->elemSize();
} }
} }
return res; return res;
@ -2525,7 +2529,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet
jdoubleArray res = env->NewDoubleArray(me->channels()); jdoubleArray res = env->NewDoubleArray(me->channels());
if(res){ if(res){
jdouble buff[me->channels()]; jdouble buff[CV_CN_MAX];//me->channels()
int i; int i;
switch(me->depth()){ switch(me->depth()){
case CV_8U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break; case CV_8U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break;

View File

@ -198,12 +198,12 @@ void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp)
void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat) void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat)
{ {
int count = v_kp.size(); int count = (int)v_kp.size();
mat.create(count, 1, CV_32FC(7)); mat.create(count, 1, CV_32FC(7));
for(int i=0; i<count; i++) for(int i=0; i<count; i++)
{ {
KeyPoint kp = v_kp[i]; KeyPoint kp = v_kp[i];
mat.at< Vec<float, 7> >(i, 0) = Vec<float, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, kp.octave, kp.class_id); mat.at< Vec<float, 7> >(i, 0) = Vec<float, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, (float)kp.octave, (float)kp.class_id);
} }
} }
#endif #endif
@ -231,7 +231,7 @@ void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat)
void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat) void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat)
{ {
int count = v_mat.size(); int count = (int)v_mat.size();
mat.create(count, 1, CV_32SC2); mat.create(count, 1, CV_32SC2);
for(int i=0; i<count; i++) for(int i=0; i<count; i++)
{ {
@ -258,12 +258,12 @@ void Mat_to_vector_DMatch(Mat& mat, vector<DMatch>& v_dm)
void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat) void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat)
{ {
int count = v_dm.size(); int count = (int)v_dm.size();
mat.create(count, 1, CV_32FC4); mat.create(count, 1, CV_32FC4);
for(int i=0; i<count; i++) for(int i=0; i<count; i++)
{ {
DMatch dm = v_dm[i]; DMatch dm = v_dm[i];
mat.at< Vec<float, 4> >(i, 0) = Vec<float, 4>(dm.queryIdx, dm.trainIdx, dm.imgIdx, dm.distance); mat.at< Vec<float, 4> >(i, 0) = Vec<float, 4>((float)dm.queryIdx, (float)dm.trainIdx, (float)dm.imgIdx, dm.distance);
} }
} }
#endif #endif

View File

@ -6,6 +6,8 @@
#ifdef HAVE_OPENCV_FEATURES2D #ifdef HAVE_OPENCV_FEATURES2D
#include "opencv2/features2d/features2d.hpp" #include "opencv2/features2d/features2d.hpp"
#undef SIMPLEBLOB // to solve conflict with wincrypt.h on windows
namespace cv namespace cv
{ {