私はフレームごとにライブカメラストリームを処理するAndroidアプリケーションを開発しています(正方形を検出するため)。プレビューコールバックでは、画像フレームをバイト配列として渡します。私のopencv関数では、そのバイト配列をマットオブジェクトに変換します。mixchannels()
opencvで関数を使用します。私のマットオブジェクトは互換性がないと思いますmixchannels()
。それを解決する方法を提案します。それを置き換えるimage
とimage1
、そこにも打たれます。助けてください。ありがとう、良い一日を!ここに私のコードがあります。
JNIEXPORT jint JNICALL Java_org_opencv_samples_tutorial3_Sample3View_FindFeatures(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray yuv, jintArray rgba)
{
jbyte* _yuv = env->GetByteArrayElements(yuv, 0);
jint* _rgba = env->GetIntArrayElements(rgba, 0);
//Mat myuv(height + height/2, width, CV_8UC1, (unsigned char *)_yuv);
Mat image(height + height/2, width, CV_8UC1, (unsigned char *)_yuv);//byte array in to mat object
Mat image1(height + height/2, width, CV_8UC3, (unsigned char *)_yuv);
Mat mrgba(height, width, CV_8UC4, (unsigned char *)_rgba);
Mat mgray(height, width, CV_8UC1, (unsigned char *)_yuv);
cvtColor(image, mrgba, CV_YUV420i2RGB ,4);
vector<vector<Point> > squares;//
vector<vector<Point> > contours;//
jint Area=0;
int thresh = 50, N = 10;
Mat pyr, timg, gray0(image.size(), CV_8U), gray;
pyrDown(image, pyr, Size(image.cols/2, image.rows/2));//reduces noice of the image,if i put'image1' here it struck too
pyrUp(pyr, timg, image.size());//reduces noice of the image
//for loop to find squares in every color plane of the image
for( int c = 0; c < 3; c++ )
{
int ch[] = {c, 0};
mixChannels(&timg, 1, &gray0, 1, ch, 1);//code struck here.if i replace 'c' with '1' it workes