sahiba202 0 Newbie Poster

I am working on a project on Augmented Reality with Android. The code captures the camera video, finds the marker and displays a cube on top of it. After this a motion vector (in the form of pixels moved in the x and y direction) is found. What I need to do is read the pixels from the GL layer and draw them again after moving them by the distance specified by the motion vector.
The GL layer is specified using the GLSurfaceView class which is a transparent layer. The problem I am facing is that when I use glReadPixels() to read the pixels and convert it into a 480x800 array (nexus one screen resolution), I get 3 different portions of the cube instead of one.
I intend to move the pixels by the motion vector after this and use glDrawPixels() to put the pixels back into the frame buffer.
Please help me with the interpretation of the same. Is there something I am missing while using glReadPixels and also if there is some other function that will help me achieve the same. I was thinking of using glBlitFrameBuffer() but this is not supported by the android GL10 class.
I have attached the part of the code where I am reading the pixels and changing them to a 2D matrix along with the image I am getting right now.
Any help will be greatly appreciated.

gl.glPixelStorei(GL10.GL_PACK_ALIGNMENT, 1);
			IntBuffer pixels = IntBuffer.allocate(384000);

			gl.glReadPixels(0, 0, 800, 480, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE ,pixels);
			
				File f = new File ("./mnt/sdcard/Sahiba_PixelData_" + flag + ".txt");
				
					if(!f.exists())
						f.createNewFile();
					FileWriter fw = new FileWriter(f);
					
					int pixelsArr [][] = new int [480][800];
					//int temp[] = pixels.array();
					int n=0;
					for(int i=0; i<480; i++){
						for(int j=0; j<800; j++){
							pixelsArr[i][j] = pixels.get(n);
								//temp[n + pixels.arrayOffset()];
							fw.write(pixelsArr[i][j] + " ");
							//fw.write(pixels.get(n) + " ");
							n++;
						}
						//fw.write("\n");
					}
			
			Log.i("GLLayer", "Pixels reading and storing finished !!!");
			}catch(Exception e){
				Log.i("GLLayer","Exception = " +e);
			}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.