Exemple #1
0
static void teardown()	{
	assert_true(check_bitmap_consistency());
	bitmap_release();
}
Exemple #2
0
static void teardown()	{
    /*verify_heap();*/ bitmap_release();
}
Exemple #3
0
void Mediator::nextStep()
{
	DWORD tm = GetTickCount();
	prevImage = curImage;
	DWORD tm1 = GetTickCount();

	bitmap *bitMap = frameReader.nextFrame();
	Picture basePic(width, height, 3);
	basePic.copyPic(bitMap->data);

	basePic = picConverter.fixDistortions(converter, basePic);
	Picture smallGreyPic = picConverter.convertColor(basePic);
	if (downscale > 1.05)
	{
		smallGreyPic = picConverter.downscale(smallGreyPic, downscale);
	}
	Picture curImage1 = smallGreyPic;//.getRectMiddle(0);// - gauss.apply(smallGreyPic);/*gauss.apply(smallGreyPic);*/
	Capture_Log::getInstance()->log_write("Preprocess time is %d\n", GetTickCount() - tm1);

	Homography h**o = homoEstimator.getHomography(prevImage.getWidth() != 0 ? prevImage : curImage1, curImage1, stepSize);
	h**o.applyDownscale(1.0 / (double)downscale);

	Homography clearHomo = kalmanHomo.observe(h**o);
	
	
	Matrix clearHomoMatrix = clearHomo.getHomoMatrix3x3();
	Matrix clHomoObr = clearHomoMatrix.obratn();
	Matrix homoMatr = h**o.getHomoMatrix3x3();
	Matrix HnoiseMatr = clHomoObr * homoMatr;

	Capture_Log::getInstance()->log_write("\n\n\n");
	Capture_Log::getInstance()->log_write("Estimated h**o is\n");
	h**o.printLog();

	Capture_Log::getInstance()->log_write("Kalman h**o is\n");
	clearHomo.printLog();

	Capture_Log::getInstance()->log_write("Kalman obratn h**o is\n");
	dif_lib::print(clHomoObr);

	Capture_Log::getInstance()->log_write("Noise h**o is\n");
	dif_lib::print(HnoiseMatr);

//	curHomo = Homography(HnoiseMatr);
	Capture_Log::getInstance()->log_write("Check base h**o is\n");
	dif_lib::print(clearHomoMatrix * HnoiseMatr);
	curHomo.printLog();
	Capture_Log::getInstance()->log_write("\n\n\n");
	
	

/*	Homography homoE = Homography();
	curHomo = homoE * beta1 + h**o * alpha1 + curHomo * (1 - alpha1 - beta1);*/

//	curImage = curImage1;
	curImage = picConverter.applyHomo(curImage1, curHomo);

	if (prevPic.getWidth() == 0)
	{
		prevPic = basePic.clone();
	}
	Gaussian gs(width, height, 2.0);
	if (0 && params.debug && bitMap->data && prevPic.getWidth() > 0)
	{
//		Capture_Log::getInstance()->log_write("Gaussian full time is %d\n", GetTickCount() - tm);
		static int frameId = 0;
		char name1[11] = "filea.jpeg";
		char name2[12] = "fileaa.jpeg";
		name1[4] += frameId;
		name2[4] += frameId;
		frameId++;
/*		Picture pic0 = gs.apply(prevPic);
		Picture pic1 = picConverter.applyHomo(basePic, h**o);
		Picture pic = gs.apply(pic1);
		double dist = tester.imgDistace(pic0.getPictureChar(), pic.getPictureChar(), 3);*/
		frameReader.saveFrame(curImage1.getPictureChar(), smallGreyPic.getWidth(), smallGreyPic.getHeight(), smallGreyPic.getColors(), name1);
/*		frameReader.saveFrame(pic.getPictureChar(), width, height, 3, name2);
		Capture_Log::getInstance()->log_write("Pictures distance is %.2f\n", dist);*/
	}

//	Picture img = gs.apply(basePic);
	tm1 = GetTickCount();
	convImage = picConverter.applyHomo(basePic, curHomo);
	Capture_Log::getInstance()->log_write("H**o time is %d\n", GetTickCount() - tm1);
	tm1 = GetTickCount();
//	convImage = gauss.apply(convImage);
	Capture_Log::getInstance()->log_write("Gauss time is %d\n", GetTickCount() - tm1);

	if (params.debug)
	{
		laplas = basePic.clone();//picConverter.convertGrey(curImage1/* - gs.apply(curImage1)*/, 3);//convImage;// - gs.apply(convImage);
	}
	else
	{
		laplas = convImage;
	}


	tm1 = GetTickCount();
	Picture rect = convImage.getRectMiddle(bandWidth);
	frameReader.saveFrame(rect.getPictureChar(), rect.getWidth(), rect.getHeight(), 3);
	
/*	rect = basePic.getRectMiddle(bandWidth);
	frameReader.saveFrame(rect.getPictureChar(), rect.getWidth(), rect.getHeight(), 3);*/

	Capture_Log::getInstance()->log_write("Save time is %d\n", GetTickCount() - tm1);

//	prevPic = basePic.clone();
	bitmap_release(bitMap);
	Capture_Log::getInstance()->log_write("Step time is %d\n\n\n", GetTickCount() - tm);
}