#include "catest.h"
#include "Halcon.h"
#include "cpp/HalconCpp.h"
using namespace Halcon;

CATest::CATest(const QString& name,int32_t id)
	: CAlgorithm(name,id)
{

}

int32_t CATest::exe(CMImage *pmimage)
{
    Hobject   Image, Region, ImageResult;
	HTuple errorText;
	HTuple Pointer, Type, Width, Height, Pointer1;
    Herror err = gen_image1_extern(&Image, "byte", pmimage->m_width, pmimage->m_height, (uintptr_t)pmimage->m_pRawImage, 0);
	get_image_pointer1(Image, &Pointer1, &Type, &Width, &Height);
	//long pt = 0;
	//tuple_int(Pointer1, &pt);
	//int pt2 = (int)pmimage->m_pRawImage;
	write_image(Image, "jpg", 0, "__11.jpg");
	get_error_text(err, &errorText);
    threshold(Image, &Region, 128, 255);
	get_image_pointer1(Image, &Pointer1, &Type, &Width, &Height);
	//tuple_int(Pointer1, &pt);
    overpaint_region(Image, Region, 255, "fill");
	get_image_pointer1(Image, &Pointer1, &Type, &Width, &Height);
	//tuple_int(Pointer1, &pt);
	write_image(Image, "jpg", 0, "__1.jpg");

	return 0;
}

void CATest::showragion(CImageContainer *pContainer)
{
    CShape* pShape=new CRect(50,50,CMPointd(100,100));
    pContainer->addShape(pShape,CImageContainer::STATIC_SHAPE);
}

