Thanks a lot for your comments.
Yes, the compiling of the first solution:
///////////////
Mat mbgra(height, width, CV_8UC3, (unsigned char *)_bgra);
cvtColor(myuv, mbgra, CV_YUV420sp2BGR, 3);
/////////////////
can be passed. And the apk files can be built.
But when I run it in android phone (SAMSUNG galaxy GT-P1000). It will
reports "quits with unexpect errors".
I use the second way to change my code. But the speed is still very
slow.
I list the main code of my app in the following:
///////////////////////////////////////
jbyte* _yuv = env->GetByteArrayElements(yuv, 0);
jint* _bgra = env->GetIntArrayElements(bgra, 0);
Mat myuv(height + height/2, width, CV_8UC1, (unsigned char
*)_yuv); /// I do not know why this "height+height/2" will work while
not "height"?
Mat mbgra(height, width, CV_8UC4, (unsigned char *)_bgra);
cvtColor(myuv, mbgra, CV_YUV420sp2BGR, 4);
Mat trcm;
cvtColor(mbgra, trcm, CV_RGBA2RGB, 3);
IplImage img1=IplImage(trcm);//since my opencv program use 'c'
style, I have to covert the mat data 'trcm' to IplImage type.
int direction=-1;
direction=motion_deter(&img1,10);//here, the motion_deter function
will do some processing to get the diretion of objects motion.
if (direction==0)
///show a circle in the screen
if (direction==1)
///show a cross in the screen
......
///////////////////////////////////
The above code runs very slowly. I guess the reason may be in the
function motion_deter. However, it works well in windows and linux. I
do not konw why it is so slow in such android opencv enviorment.
It works on galaxy GT-P1000.
The preview size may be 640*480 or higher (actually, I do not know
how to see it and adjust it).
And can I set the video data size to a smaller one?( it seems that
cvSetCaptureProperty can not work)
Bests,
Stone_Liu
> > > - Show quoted text -- Hide quoted text -