Jump to content

  • Log In with Google      Sign In   
  • Create Account

run_g

Member Since 18 Dec 2006
Offline Last Active Aug 21 2014 10:33 AM

Topics I've Started

iterator output not in sync

01 July 2014 - 05:20 PM

my iterator output (below) is picking up diagonals of vector3D array, why? how can i fix this code so the output is the same as the 2-d array output (below also)?

Or is it a fact that iterators cannot be used with 2d arrays

 

many thanks        (just edited to add some comments now. Hope that helps) 

public class myIterator{
	
	List<vector3D> vec = new ArrayList<vector3D>();
	vector3D  myTwoDimVec[][] = new vector3D[3][5];
	
	myIterator( ){
		
		for(int i=0; i<myTwoDimVec.length; i++){      //double loop to traverse 2d vector array
			for(int j=0; j<myTwoDimVec[i].length; j++){
          
                              //setting values the x,y,z data feild of the vector3D 
                              // in order to make each data unique value and thus debugging is tractable
                              // i am incrementing the data by 1 using i * myTwoDimVec[i].length + j
                              //                   this is         row* MaxColumnLength + current column
                              // in other words if i do not increase by 1 at all then it will be
                              //myTwoDimVec[i][j] = new vector3D(10, 20, 30 );  and all the data will look the same
                              //but this code makes it 10, 20, 30    11, 21, 31    12, 22, 32 etc    
                              // so with this difference i can track which data went missing
                                 
				myTwoDimVec[i][j] = new vector3D(10+(i*myTwoDimVec[i].length+j), 20+(i*myTwoDimVec[i].length+j), 30+(i*myTwoDimVec[i].length+j));

				vec.add( myTwoDimVec[i][j] );            // adding to the arraylist

			}
		}
		
	}
	
	public void createListVector3D(){
		
		for(int i=0; i<myTwoDimVec.length; i++){           //double loop to print out the 
			for(int j=0; j<myTwoDimVec[i].length; j++){// data directly- not using *.hasNext
				
				System.out.println("2 dimen array output   "+myTwoDimVec[i][j].x + "   " + myTwoDimVec[i][j].y + "   " + myTwoDimVec[i][j].z );
			}
		}
		
		ListIterator<vector3D>  vecIterator = vec.listIterator();

		System.out.println( "=============================================================");

		while( vecIterator.hasNext()){   // outputing using hasNext
			System.out.println( "iterator list output   " + vecIterator.next().x +  "   " + vecIterator.next().y  +  "   " + vecIterator.next().z  );
		}
		

	}
	
}

public class conceptPractice {
	
	static myIterator scanArray;
	
	public static void main( String[] args ){
		
		scanArray = new myIterator();
		scanArray.createListVector3D();
	}
}

2 dimen array output   10.0   20.0   30.0
2 dimen array output   11.0   21.0   31.0
2 dimen array output   12.0   22.0   32.0
2 dimen array output   13.0   23.0   33.0
2 dimen array output   14.0   24.0   34.0
2 dimen array output   15.0   25.0   35.0
2 dimen array output   16.0   26.0   36.0
2 dimen array output   17.0   27.0   37.0
2 dimen array output   18.0   28.0   38.0
2 dimen array output   19.0   29.0   39.0
2 dimen array output   20.0   30.0   40.0
2 dimen array output   21.0   31.0   41.0
2 dimen array output   22.0   32.0   42.0
2 dimen array output   23.0   33.0   43.0
2 dimen array output   24.0   34.0   44.0
=============================================================
iterator list output   10.0   21.0   32.0
iterator list output   13.0   24.0   35.0
iterator list output   16.0   27.0   38.0
iterator list output   19.0   30.0   41.0
iterator list output   22.0   33.0   44.0

I've got problems with interviews

28 June 2014 - 12:25 PM

I've got serious problems with interviews ( I live in the UK ...  not sure if my experience is the same for those in the US or else where)

 

When i was in university over 13 years ago i practice code and definitions on paper - mainly to pass exams

 

But since leaving uni i coded straight to my computer....  because i code to develop projects (not to pass exams), and with advanced IDEs such as eclipse i can concentrate on developing algorithm. Of course i do analysis on paper - vector maths, algorithms, data-user interactions, image processing, rough pseudo-code  analysis... on paper. But never proper coding and never definitions because its never been necessary for my code to work. I get the full picture writing the code direct to my computer.

 

And i don't need to rehearse concepts in English because i know it. My focus can momentarily shift from a concept (depending on what i'm currently working on) and there are so many... but i can easily reference anything when i need it.

 

I don't even have to memorise definitions to get complicated code to work.

 

simple example: don't know the definition of anonymous inner class but i have used it b4 because once i see an example of how its used, i have always used it. My description of how i use didn't cut it with them, I have to define it using some key words. 

Ok now with hindsight i can describe it better.  But my using it wouldn't necessarily improve and next time it would be something else

 

In my opinion core algorithm development on computer (not on paper) should be the best way to test the competence and intelligence of a developer 

 

Yet whenever i go for an interview every time again and again and again (despite pre-asking to be tested by writing code to computer) i kept being tested by definitions and crossword-puzzle kind of coding questions on paper (where i can't get- in non-trivial situations- a full picture of the problem)

 

Then someone calls me dumb... because i scored 6/50

They don't even consider my portfolio-projects - taking the so-called test to over-rule my portfolio 

 

Now i'm forced to work in KFC to pay my bills

 

Why do employers insist on this way of assessing programmers?

Why are they so naive?

What's the experience of others (not if you a boss your-self) on this forum?  


OutOfMemory error while loading bitmaps / camera capture Bitmaps

20 December 2013 - 10:46 PM

Hello I need your expertise help.

 

I have been stuck with OutOfMemory error for a long while. For some time I concentrated on other parts of the program, but now i have to get it sorted. Seaching through the web extensively, particularly on stackoverflow i realised its one of the most common problems talked about and i thought i won't be long before i get it sorted from the numerous solutions suggested, but how wrong i was.

 

dalvikvm-heap                Out of memory on a 2834945-byte allocation.

Camera-JNI                   Couldn't allocate byte array for JPEG data

 

I tralled through suggested solutions for weeks but to no avail.

 

Crucially i couldn't adapt the solution on

 

http://developer.android.com/training/displaying-bitmaps/load-bitmap.html and others suggested solutions to my own code.

 

These all expect you are loading bitmap from the resource hence reflected in the parameters

 

 

 

public static Bitmap 
decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight)

I was using bitmap from live camera and also loading bitmap from the sdcard.

The whole program is too large to place here but here are the relevant parts, sufficient to see to the problem.

The camera captures live photos in cycles. After processing each bitmap I expect to discard it and process the next capture. I kept having OOM errors. Then I used a loaded bitmap from sdcard in its place so that that problem wouldn't slow me down. Even then i stll have OOM errors . I have to admit the size of the loaded bitmap === to captured live bitmap is huge 3264 X 2448 But the point is all the inbuilt code solution to manage this size and scale it down effeciently have failed to work. I hope your expertise would be able to see a solution, thanks

extract relevant code only so it can be easy to follow


byte[] tempdata;
String     CAMERA_PIC_DIR,ImageDir;
public Bitmap  directCameraSaveBM1;

CAMERA_PIC_DIR = "/DCIM/Camera/";
ImageDir = Environment.getExternalStorageDirectory().getAbsolutePath() + CAMERA_PIC_DIR;

........
........

in code below

directCameraSaveBM1   =   BitmapFactory.decodeFile(ImageDir+"useThisPhoto10aa.jpg");                 //loaded bitmap..

 

bm.recycle();                                   //replacing this live bitmap, but this is the real one i intend to use eventually except that it fails, loaded also fails OOM

bm = null;

	PictureCallback mjpeg = new PictureCallback() {
		
		public void onPictureTaken(byte[] data, Camera c) {
			mCamera.startPreview();
			
			if(data !=null) {
				tempdata=data;
				done();
			}
		}
	};
	

	void done( ) {
		
		BitmapFactory.Options options = new BitmapFactory.Options();   //for direct cam capture
		options.inSampleSize = 8;        
		
		bm = BitmapFactory.decodeByteArray(tempdata,  0, tempdata.length, options); 
				               // 
		int pNum=11;
		directCameraSaveBM1 = BitmapFactory.decodeFile(ImageDir+"useThisPhoto10aa.jpg");///remove comment
//		float	px = (float) getBaseContext().getResources().getDisplayMetrics().densityDpi/160f;//
		
		bm.recycle();   bm  = null;

		parameters = mCamera.getParameters();                    
		previewsize = parameters.getPreviewSize();               
		rWidth = previewsize.width;                  //800  480
   	    rHeight = previewsize.height;                //480  180   
   	 
   	    miniW = noticeButton4.getWidth();                             
   	    miniH = noticeButton4.getHeight();
   			    	
   	    Log.v("rWidth  "+Integer.toString(rWidth), "   rHeight   "+Integer.toString(rHeight));
   	    Globals.bm3G = Bitmap.createScaledBitmap(directCameraSaveBM1, rWidth, rHeight, false);   

   	    
    	lH = ((rHeight/2) - (miniH/2));
    	uH = ((rHeight/2) + (miniH/2));
 		     	
    	lW = ((rWidth/2) - (miniW/2));
    	uW = ((rWidth/2) + (miniW/2));

        //// a lot of crap code follows......



















                        .......
                     /// lots of image processing code and stuff
                       .........
	    save_bm_image( ImageDir, pNum );/**/
	    Runtime.getRuntime().gc();
    } //done()

	void save_bm_image( String bname, int choose ){
		if     ( choose == 3 )     fname = fname3;
		else if( choose == 4 )     fname = fname4;
		else if( choose == 5 )     fname = fname5;
			
		File file = new File (bname, fname);   ///saving bitmap to file
		if (file.exists ()) file.delete (); 
		try {
		       FileOutputStream out = new FileOutputStream(file);
		       Globals.bm3G.compress(Bitmap.CompressFormat.PNG, 90, out);
		       out.flush();
		       out.close();	
		} catch (Exception e) {
		       e.printStackTrace();
		}	
		
		name = bname + fname;
	}

I hope someone can spot why I have this problem and offer code solution tips

 Lots of thanks for any help


looking for gl function that returns surface color

09 January 2013 - 04:49 PM

This might seem simple but i just cant find the answer:- in opengl es (fixed function) lets say u texture map a bitmap to a regular polygon- so the bitmap is now stretched and thus relative position of the color points on the rectangle is different from original bitmap- is there is a way ... I mean a gl. function that- if given the x,y coord on the rectangle surface relative to say the top left rectangle coord as a parameter- will return the colour of that point? Many thanks in advance

gl function for "returning" a polygon point surface colour?

07 January 2013 - 10:38 AM

This might seem simple but i just cant find the answer:- in opengl es (fixed function) lets say u texture map a bitmap to a regular polygon- so the bitmap is now stretched and thus relative position of the color points on the rectangle is different from original bitmap- is there is a way ... I mean a gl. function that- if given the x,y coord on the rectangle surface relative to say the top left rectangle coord as a parameter- will return the colour of that point?
Thanks in advance
PLEASE i hope someone can help on this... I'm kind-of stuck. many thanks

PARTNERS