我正在为Android创建一个运动检测应用程序。虽然我有我的检测算法的问题:比较不断重新填充的2d阵列
public boolean compareBitmaps()
{
/*I'm creating 2 x 2D arrays which will continually be repopulated
every 2 frames with the pixel data of that frame based on even or odd
(frames are collected in an ArrayList 'BIT')
BIT(0) will be stored in compare1
BIT(1) will be stored in compare2
BIT(2) will be stored in compare1 and so on...*/
int [][] compare1 = new int[width][height];
int [][] compare2 = new int[width][height];
int bmpCount = BIT.size();
boolean noMotion = true;
//This is where I determine wheter even or odd using the modulus %
for (int x=0; x<bmpCount; x++)
if(x%2!=0)
{
System.out.println("Odd");
getPixels1(compare1, x);
}
else
{
System.out.println("Even");
getPixels2(compare2, x);
}
//Here I'm looking to continually compare the returned pixel colours
// of the 2D arrays
if(!Arrays.deepEquals(compare1, compare2))
{
System.out.println("No Motion");
return noMotion = false;
}
else
{
return noMotion = true;
}
}
private void getPixels1(int[][] compare1, int x)
{
for(int i = 0; i<width; i++)
{
for(int j=0; j<height; j++)
{
compare1[j][i] = BIT.get(x).getPixel(j, i);
}
}
}
private void getPixels2(int[][] compare2, int x)
{
for(int i = 0; i<width; i++)
{
for(int j=0; j<height; j++)
{
compare2[j][i] = BIT.get(x).getPixel(j, i);
}
}
}
我使用println()
帮我调试, - 目前控制台打印出“奇”这(纠正我,如果我错了)是错误的元素(0)?当我下一步完成应用程序休息时。
有人能看到我在做什么错了,任何帮助,将不胜感激
非常感谢,
当你在实现运动检测型应用程序,并比较每个偶数和奇数帧,从我的小知识,我认为这是太快,会消耗大量的CPU功率的,我的建议是框架在低速率一些比较像15帧之后的东西。 –
对不起,15帧后你比较什么?就像比较第0帧和第14帧以及第15帧和第29帧一样? – Ledgey1101
只是一个友好的提醒。我注意到你没有接受任何问题的答案。你知道你可以接受答案来证明它解决了你的问题吗?只需点击投票箭头旁边的复选框即可。这让社区知道你正在积极参与你的问题。 –