/*************************************************************************\
* "$RCSfile: CamFunctions.cpp,v $"                                        *
***************************************************************************
* Information by CVS or VSS:                                              *
*     Last check in on: $Date: 2010-10-04 14:03:19 $                      *
*     by                $Author: schluckebier $
*     Revision        : $Revision: 1.1 $                                 *
\*************************************************************************/
/*! \file CamFunctions.cpp
*	\brief Common Functions for all Camera live modules
*	\author (c) 2009 IMAGO Technologies GmbH
**************************************************************************/

#include <std.h>
#include <clk.h>
#include <string.h>
#include "vision_box.h"
#include "GUI_Lib.h"
#include "Example.h"

/*************************************************************************/
void CAMShowInfo(CIMAGE *pImage, CIMAGE *pcCamImage, YIMAGE *pyCamImage,
	int PosX, int PosY, bool bColor, char *pCamName)
/*************************************************************************/
/*! @brief Prints information in camera image and shows the image.
	@param pImage Display image
	@param pcCamImage Color camera image
	@param pyCamImage Gray camera image
	@param xOff x offset in camera image
	@param yOff y offset in camera image
	@param PosX x destination in display image
	@param PosY y destination in display image
	@param bColor Color/gray camera image
	@param pCamName Camera name
**************************************************************************/
{
	const char oOo[] = ".oOo";
	char Text[64];
	int camWidth, camHeight;
	int camMinHeight;
	int t1;
	unsigned int usec, fps;
	bool bInfo = true;
	static int k = 0;
	static unsigned int t0 = 0;

	camWidth  = pyCamImage->Width;
	camHeight = pyCamImage->Height;
	camMinHeight =  _min2(camHeight, pImage->Height);

	// *** Calculate frames per second ***
	t1 = CLK_gethtime();
	usec = (t1-t0) / (VIB_Freq/8);
	t0 = t1;
	fps = (int)(1000000.0/usec+0.5);
	sprintf(Text, "%dx%d %2d fps %c", camWidth, camHeight, fps, oOo[++k%4]);

	// *** Print info text ***
	if (bInfo)
	{
		GUI_TextOutY(pyCamImage, 12, camMinHeight-42, pCamName);
		GUI_TextOutY(pyCamImage, 12, camMinHeight-22, Text);
	}
	GUI_DisplayY(pyCamImage, PosX, PosY);
}

/*************************************************************************/
