public int getScoreEndGame(BufferedImage screenshot) {
		// crop score image
		BufferedImage scoreImage = screenshot.getSubimage(370, 265, 100, 32);
	
		

        // transform template images into black-white format
		BufferedImage[] endGameNumberTemplates = { extractNumber(_endGame0),
				extractNumber(_endGame1), extractNumber(_endGame2),
				extractNumber(_endGame3), extractNumber(_endGame4),
				extractNumber(_endGame5), extractNumber(_endGame6),
				extractNumber(_endGame7), extractNumber(_endGame8),
				extractNumber(_endGame9) };
		
        
		// extract characters
		int mask[][] = new int[scoreImage.getHeight()][scoreImage.getWidth()];
		for (int y = 0; y < scoreImage.getHeight(); y++) {
			for (int x = 0; x < scoreImage.getWidth(); x++) {
				final int colour = scoreImage.getRGB(x, y);
				mask[y][x] = (((colour & 0x00ff0000) >> 16) > 192) ? 1 : -1;
			}
		}
		scoreImage = VisionUtils.int2image(mask);
		mask = VisionUtils.findConnectedComponents(mask);
		Rectangle[] letters = VisionUtils.findBoundingBoxes(mask);
		Arrays.sort(letters, new RectLeftOf());
        
		// decode letters
		int score = 0;
		for (int i = 0; i < letters.length; i++) {
			if (letters[i].width < 2)
				continue;

			BufferedImage letterImage = scoreImage.getSubimage(letters[i].x,
					letters[i].y, letters[i].width, letters[i].height);

			int value = 0;
			
			//init min different between target number and template
			int minDiff = Integer.MAX_VALUE;
			
			//loop to find a template with minimum difference
			for (int j = 0; j < 10; j++) {
		        int diff = getPixelDifference(letterImage, endGameNumberTemplates[j]);
				if(diff < minDiff){
					minDiff = diff;
					value = j;
				}
			}
			score = 10 * score + value;
		}

        /*
        if (score != prevScore)
        {
            saved = false;
            repeatCount = 0;
            prevScore = score;
        }
        else if (score != 0 && !saved)
        {
            repeatCount++;
            if (repeatCount > 0)
            {
                saved = true;
                try {
                    File outputfile = new File("scoreImage/" + score + ".png");
                    ImageIO.write(saveImage, "png", outputfile);
                } catch (IOException e) {
                
                }
            }
        }*/
        
		/*
		 * VisionUtils.drawBoundingBoxes(scoreImage, letters, Color.BLUE); if
		 * (_debug == null) { _debug = new ShowDebuggingImage("score",
		 * scoreImage); } else { _debug.refresh(scoreImage); }
		 */

		return score;
	}