Exemple #1
0
CfgList* CfgValue::LoadFile (std::string name)
{
	InputBuffer buf;

	FILE *f = fopen (name.c_str(), "rb");
	if (!f) 
		throw ContentException(SPrintf("Failed to open file %s\n", name.c_str()));

	fseek (f, 0, SEEK_END);
	buf.len = ftell(f);
	buf.data = new char [buf.len];
	fseek (f, 0, SEEK_SET);
	if (!fread (buf.data, buf.len, 1, f))
	{
		fclose (f);
		delete[] buf.data;
		throw ContentException(SPrintf("Failed to read file %s\n", name.c_str()));
	}
	buf.filename = name.c_str();

	fclose (f);

	CfgList *nlist = new CfgList;
	try {
		nlist->Parse (buf, true);
	}  catch (const ContentException &e) {
		delete[] buf.data;
		delete nlist;
		throw e;
	}
	delete[] buf.data;
    return nlist;
}
Exemple #2
0
void SmallImageTest()
{
	CPUTracker *tracker = new CPUTracker(50,50, 16);

	GenerateTestImage(ImageData(tracker->srcImage, tracker->GetWidth(), tracker->GetHeight()), tracker->width/2,tracker->height/2, 9, 0.0f);
	FloatToJPEGFile("smallimg.jpg", tracker->srcImage, tracker->width, tracker->height);

	vector2f com = tracker->ComputeMeanAndCOM(0);
	dbgout(SPrintf("COM: %f,%f\n", com.x, com.y));
	
	vector2f initial(25,25);
	bool boundaryHit = false;
	vector2f xcor = tracker->ComputeXCorInterpolated(initial, 2, 16, boundaryHit);
	dbgout(SPrintf("XCor: %f,%f\n", xcor.x, xcor.y));
	//assert(fabsf(xcor.x-15.0f) < 1e-6 && fabsf(xcor.y-15.0f) < 1e-6);

	int I=4;
	vector2f pos = initial;
	for (int i=0;i<I;i++) {
		bool bhit;
		vector2f np = tracker->ComputeQI(pos, 1, 32, 4, 1, 1, 16, bhit);
		dbgprintf("qi[%d]. New=%.4f, %.4f;\tOld=%.4f, %.4f\n", i, np.x, np.y, pos.x, pos.y);
	}


	FloatToJPEGFile("debugimg.jpg", tracker->GetDebugImage(), tracker->width, tracker->height);
	delete tracker;
}
Exemple #3
0
void SWIApp::draw()
{
	if (!best_list.empty()) {
		float s=40;
		float aspect = RenderUtil::height / (float)RenderUtil::width;
		RenderUtil::beginCamera(Box2(-s,-s*aspect,s,s*aspect));
		glColor3ub(0,0,255);
		glPushMatrix();
			glTranslatef(-20.0f, 0.0f, 0.0f);
			best->render(15.0f);
			RenderUtil::drawCircle(Vector2(), best->radius, false);
		glPopMatrix();
		glColor3ub(0,0,255);
		SqcConfig* last_best = best_list.back();
		glPushMatrix();
			glTranslatef(20.0f, 0.0f, 0.0f);
			last_best->render(15.0f);
			RenderUtil::drawCircle(Vector2(), last_best->radius, false);
		glPopMatrix();
		RenderUtil::endCamera();

		graph.render(Box2(20, 500, 800-20, 590));

		glColor4ub(255,255,255,255);
		GlyphRenderer::getDefaultRenderer()->drawString(Vector2(100, 50), 20.0f, SPrintf("Overall r=%f. F=%f", best->radius, best->fitness).c_str());
		GlyphRenderer::getDefaultRenderer()->drawString(Vector2(500, 50), 20.0f, SPrintf("Last r=%f. F=%f", last_best->radius, last_best->fitness).c_str());
	}
	GlyphRenderer::getDefaultRenderer()->drawString(Vector2(100, 70), 20.0f, SPrintf("Swarm Intelligence Demo.  Sigma=%f", sigma).c_str());
}
Exemple #4
0
void QueuedCPUTracker::SetPixelCalibrationImages(float* offset, float* gain)
{
	if (zlut_count > 0) {
		int nelem = cfg.width*cfg.height*zlut_count;

		if (calib_gain == 0 && gain)  {
			calib_gain = new float[nelem];
			memcpy(calib_gain, gain, sizeof(float)*nelem);
		}
		else if (calib_gain && gain == 0) {
			delete[] calib_gain;
			calib_gain = 0;
		}

		if (calib_offset == 0 && offset) {
			calib_offset = new float[nelem];
			memcpy(calib_offset, offset, sizeof(float)*nelem);
		}
		else if (calib_offset && offset == 0) {
			delete[] calib_offset;
			calib_offset = 0;
		}

#ifdef _DEBUG
		std::string path = GetLocalModulePath();
		for (int i=0;i<zlut_count;i++) {
			if(calib_gain) FloatToJPEGFile( SPrintf("%s/gain-bead%d.jpg", path.c_str(), i).c_str(), &calib_gain[cfg.width*cfg.height*i], cfg.width,cfg.height);
			if(calib_offset) FloatToJPEGFile( SPrintf("%s/offset-bead%d.jpg", path.c_str(), i).c_str(), &calib_offset[cfg.width*cfg.height*i], cfg.width,cfg.height);
		}
#endif
	}
}
Exemple #5
0
MiniDumper::MiniDumper(const TCHAR * szDumpFilename, const TCHAR * szDumpMsg)
{
	pThis = this;

	SPrintf(m_szDumpFilename, FILENAME_MAX, szDumpFilename);
	SPrintf(m_szDumpMsg, FILENAME_MAX, szDumpMsg);

	::SetUnhandledExceptionFilter( TopLevelFilter );
}
Exemple #6
0
sptr<IBinder>
BProcess::GetStrongProxyForHandle(int32_t handle)
{
    DAP(GetStrongProxyForHandle);
    sptr<IBinder> r;

    {
        SNestedLocker::Autolock _l(m_handleRefLock);

#if COUNT_PROXIES
        if (handle > maxProxy) {
            maxProxy = handle;
            bout << "Now using descriptor #" << handle << endl;
        }
#endif

#if 0
#ifdef TRACK_CLASS_NAME
        TEST_TRACKED_CLASS(handle);
        if (tracked) {
            bout << "Pr #" << SysProcessID() << ": BProcess::GetStrongProxyForHandle(" << (void*)handle << ")" << endl;
        }
#endif
#endif

        IBinder* &b = BinderForHandle(handle);

        // We need to create a new BpBinder if there isn't currently one, OR we
        // are unable to acquire a weak reference on this current one.  See comment
        // in GetWeakProxyForHandle() for more info about this.
        if (b == NULL || !b->AttemptIncWeak((void*)s_processID)) {
            b = new B_NO_THROW BpBinder(handle);
            r = b;
#if HANDLE_DEBUG_MSGS
            bout << SPrintf("BProcess Creating strong BpBinder 0x%08x for handle %04x", b, handle) << endl;
#endif
        } else {
            // This little bit of nastyness is to allow us to add a primary
            // reference to the remote proxy when this team doesn't have one
            // but another team is sending the handle to us.
            b->ForceIncStrong((void*)s_processID);
            r = b;
            B_DEC_STRONG(b, (void*)s_processID);
            B_DEC_WEAK(b, (void*)s_processID); // FFB: safe
#if HANDLE_DEBUG_MSGS
            bout << SPrintf("BProcess Forcing a strong BpBinder 0x%08x for handle %04x", b, handle) << endl;
#endif
        }
    }

    return r;
}
Exemple #7
0
wptr<IBinder>
BProcess::GetWeakProxyForHandle(int32_t handle)
{
    DAP(GetWeakProxyForHandle);
    wptr<IBinder> r;

    {
        SNestedLocker::Autolock _l(m_handleRefLock);

#if 0
#ifdef TRACK_CLASS_NAME
        TEST_TRACKED_CLASS(handle);
        if (tracked) {
            bout << "Pr #" << SysProcessID() << ": BProcess::GetWeakProxyForHandle(" << (void*)handle << ")" << endl;
        }
#endif
#endif

#if COUNT_PROXIES
        if (handle > maxProxy) {
            maxProxy = handle;
            bout << "Now using descriptor #" << handle << endl;
        }
#endif

        IBinder* &b = BinderForHandle(handle);

        // We need to create a new BpBinder if there isn't currently one, OR we
        // are unable to acquire a weak reference on this current one.  The
        // AttemptIncWeak() is safe because we know the BpBinder destructor will always
        // call ExpungeHandle(), which acquires the same lock we are holding now.
        // We need to do this because there is a race condition between someone
        // releasing a reference on this BpBinder, and a new reference on its handle
        // arriving from the driver.
        if (b == NULL || !b->AttemptIncWeak((void*)s_processID)) {
            b = new B_NO_THROW BpBinder(handle);
            r = b;
#if HANDLE_DEBUG_MSGS
            bout << SPrintf("BProcess Creating weak BpBinder 0x%08x for handle %04x", b, handle) << endl;
#endif
        } else {
            r = b;
            b->DecWeak((void*)s_processID);
#if HANDLE_DEBUG_MSGS
            bout << SPrintf("BProcess already had weak BpBinder 0x%08x for handle %04x", b, handle) << endl;
#endif
        }
    }

    return r;
}
Exemple #8
0
void BuildConvergenceMap(int iterations)
{
	int W=80, H=80;
	char* data=new char[W*H];
	FILE* f=fopen("singlebead.bin", "rb");
	fread(data,1,80*80,f);
	fclose(f);

	float testrange=20;
	int steps=100;
	float step=testrange/steps;
	vector2f errXCor, errQI;
	CPUTracker trk(W,H,40);

	// Get a good starting estimate
	trk.SetImage8Bit((uchar*)data,W);
	vector2f com = trk.ComputeMeanAndCOM();
	bool boundaryHit;
	vector2f cmp = trk.ComputeQI(com,8,80,64,ANGSTEPF,2,25,boundaryHit);

	float *xcorErrMap = new float[steps*steps];
	float *qiErrMap = new float[steps*steps];

	for (int y=0;y<steps;y++){
		for (int x=0;x<steps;x++)
		{
			vector2f initial (cmp.x+step*(x-steps/2), cmp.y+step*(y-steps/2) );
			vector2f xcor = trk.ComputeXCorInterpolated(initial, iterations, 64, boundaryHit);
			vector2f qi = trk.ComputeQI(initial, iterations, 80, 64,ANGSTEPF,2,30,boundaryHit);

			errXCor.x += fabs(xcor.x-cmp.x);
			errXCor.y += fabs(xcor.y-cmp.y);
			xcorErrMap[y*steps+x] = distance(xcor,cmp);

			errQI.x += fabs(qi.x-cmp.x);
			errQI.y += fabs(qi.y-cmp.y);
			qiErrMap[y*steps+x] = distance(qi,cmp);
		}
		dbgprintf("y=%d\n", y);
	}
	

	WriteImageAsCSV(SPrintf("xcor-err-i%d.csv", iterations).c_str(), xcorErrMap, steps,steps);
	WriteImageAsCSV(SPrintf("qi-err-i%d.csv", iterations).c_str(), qiErrMap, steps,steps);

	delete[] qiErrMap;
	delete[] xcorErrMap;
	delete[] data;
}
Exemple #9
0
void TestBoundCheck()
{
	CPUTracker *tracker = new CPUTracker(32,32, 16);
	bool boundaryHit;

	for (int i=0;i<10;i++) {
		float xp = tracker->GetWidth()/2+(rand_uniform<float>() - 0.5) * 20;
		float yp = tracker->GetHeight()/2+(rand_uniform<float>() - 0.5) * 20;
		
		GenerateTestImage(ImageData(tracker->srcImage, tracker->GetWidth(), tracker->GetHeight()), xp, yp, 1, 0.0f);

		vector2f com = tracker->ComputeMeanAndCOM();
		dbgout(SPrintf("COM: %f,%f\n", com.x-xp, com.y-yp));
	
		vector2f initial = com;
		boundaryHit=false;
		vector2f xcor = tracker->ComputeXCorInterpolated(initial, 3, 16, boundaryHit);
		dbgprintf("XCor: %f,%f. Err: %d\n", xcor.x-xp, xcor.y-yp, boundaryHit);

		boundaryHit=false;
		vector2f qi = tracker->ComputeQI(initial, 3, 64, 32, ANGSTEPF, 1, 10, boundaryHit);
		dbgprintf("QI: %f,%f. Err: %d\n", qi.x-xp, qi.y-yp, boundaryHit);
	}

	delete tracker;
}
Exemple #10
0
void d_assert(char *str, char *file, int line)
{
	std::string msg = SPrintf("Assertion \"%s\" failed at line %d in \'%s\'\n", str, line, file);
	d_trace (msg.c_str());

	throw std::runtime_error(msg.c_str());
}
void DeviceManDX12::Destroy()
{
	Flush();
	commandList.Reset();
	commandQueue.Reset();
	swapChain.Reset();
	for (FrameResources& res : frameResources) {
		res.renderTarget.Reset();
		res.commandAllocator.Reset();
		res.srvHeap.Reset();
		res.mappedConstantBuffer = nullptr;
		if (res.constantBuffer) {
			res.constantBuffer->Unmap(0, nullptr);
		}
		res.constantBuffer.Reset();
		res.fenceValueToGuard = 0;
	}
	rtvHeap.Reset();
	depthStencil.Reset();
	dsvHeap.Reset();
	fence.Reset();
	fenceValue = 1;
	frameIndex = 0;
	int cnt = device.Reset();
	if (cnt) {
		MessageBoxA(GetActiveWindow(), SPrintf("%d leaks detected.", cnt), "DX12 leaks", MB_OK);
	}
}
Exemple #12
0
bool ZFileExtDlg::SetExtWithProgram(const tstring & strProgramName, const tstring & strExt, tstring strFullProgramPath, const tstring & strIcon, int iIconIndex)
{
	ZFileExtReg fileExtReg;


	if ( strFullProgramPath.empty() )
	{
		// get full file path to program executable file
		TCHAR szProgPath[MAX_PATH] = { 0 };
		::GetModuleFileName(NULL, szProgPath, sizeof(szProgPath) / sizeof(TCHAR));

		strFullProgramPath = szProgPath;
	}

	tstring strTempText;

	fileExtReg.m_strExtension = strExt.c_str();

	// 프로그램에게 인자를 넘겨줄 때의 full path 를 만든다.
	strTempText  = strFullProgramPath;
	strTempText += TEXT(" \"%1\"");
	fileExtReg.m_strShellOpenCommand = strTempText.c_str();
	fileExtReg.m_strDocumentShellOpenCommand = strTempText.c_str();

	// 레지스트리에 등록할 때의 프로그램의 이름과 확장자를 정한다.
	tstring strClassName = strProgramName;
	strClassName += TEXT(".");
	strClassName += strExt;
	fileExtReg.m_strDocumentClassName = strClassName.c_str();

	// 확장자에 맞는 기본 아이콘을 지정한다.
	if ( strIcon.size() <= 0 )
	{
		// 아이콘 프로그램을 지정하지 않으면 원래 프로그램의 첫번째 아이콘을 쓴다.
		strTempText  = strFullProgramPath;
		strTempText += TEXT(",0");
	}
	else
	{
		// 아이콘 프로그램을 지정했으면 icon 번호를 쓴다.
		if ( iIconIndex < 0 )
		{
			assert(iIconIndex >= 0 );
			iIconIndex = 0;
		}

		strTempText = strIcon;
		strTempText += TEXT(",");

		TCHAR szTemp[COMMON_BUFFER_SIZE] = { 0 };
		SPrintf(szTemp, COMMON_BUFFER_SIZE, TEXT("%d"), iIconIndex);
		strTempText += szTemp;
	}
	fileExtReg.m_strDocumentDefaultIcon = strTempText.c_str();

	// 설정된 값으로 레지스트리를 등록한다.
	fileExtReg.SetRegistries();

	return true;
}
BSharedObject::~BSharedObject()
{
	//bout << "Destroying BSharedObject: " << this << endl;
#if TRACK_SHARED_OBJECTS
	const int32_t r = SysAtomicDec32(&g_numSharedObjects);
	bout << "Unloaded BSharedObject, " << (r-1) << " remaining." << endl;
#endif
	
#if 0
	bout << SPrintf("BSharedObject %p destructor called (area %ld)\n", this, m_handle);
	SCallStack stack;
	stack.Update();
	bout << stack << endl;
	stack.LongPrint(bout);
#endif

	//SetResourceDatabase(NULL);

	if (m_source.IsDefined() && m_handle != B_BAD_IMAGE_ID) {
		#if SHOW_LOAD_UNLOAD
		if (ShowLoadUnload()) {
			bout << "Unloading BSharedObject " << this << " (handle " << m_handle
					<< ", path " << m_source.AsString() << endl;
		}
		#endif
		dlclose(m_handle);
		m_handle = B_BAD_IMAGE_ID;
	}
}
Exemple #14
0
void OnePixelTest()
{
	CPUTracker* tracker = new CPUTracker(32,32, 16);

	tracker->GetPixel(15,15) = 1;
	dbgout(SPrintf("Pixel at 15,15\n"));
	vector2f com = tracker->ComputeMeanAndCOM();
	dbgout(SPrintf("COM: %f,%f\n", com.x, com.y));
	
	vector2f initial(15,15);
	bool boundaryHit = false;
	vector2f xcor = tracker->ComputeXCorInterpolated(initial,2, 16, boundaryHit);
	dbgout(SPrintf("XCor: %f,%f\n", xcor.x, xcor.y));

	assert(xcor.x == 15.0f && xcor.y == 15.0f);
	delete tracker;
}
Exemple #15
0
tstring toString(int i)
{
	const int szSize = 20;
	TCHAR szTemp[szSize];
	SPrintf(szTemp, szSize, TEXT("%d"), i);

	return tstring(szTemp);
}
Exemple #16
0
void ScatterBiasArea(int roi, float scan_width, int steps, int samples, int qi_it, float angstep)
{
	std::vector<float> u=linspace(roi/2-scan_width/2,roi/2+scan_width/2, steps);
	
	QTrkComputedConfig cfg;
	cfg.width=cfg.height=roi;
	cfg.qi_angstep_factor = angstep;
	cfg.qi_iterations = qi_it;
	cfg.qi_angular_coverage = 0.7f;
	cfg.qi_roi_coverage = 1;
	cfg.qi_radial_coverage = 1.5f;
	cfg.qi_minradius=0;
	cfg.zlut_minradius=0;
	cfg.zlut_angular_coverage = 0.7f;
	cfg.zlut_roi_coverage = 1;
	cfg.zlut_radial_coverage = 1.5f;
	cfg.zlut_minradius = 0;
	cfg.qi_minradius = 0;
	cfg.com_bgcorrection = 0;
	cfg.xc1_profileLength = roi*0.8f;
	cfg.xc1_profileWidth = roi*0.2f;
	cfg.xc1_iterations = 1;
	cfg.Update();

	ImageData lut,orglut = ReadLUTFile("10x.radialzlut#4");
	vector3f ct(roi/2,roi/2,lut.h/2 + 0.123f);
	float dx = scan_width/steps;

	QueuedCPUTracker trk(cfg);
	ResampleLUT(&trk, &orglut, orglut.h, &lut);
	int maxval = 10000;

	ImageData tmp=ImageData::alloc(roi,roi);
	GenerateImageFromLUT(&tmp, &lut, 0, cfg.zlut_maxradius, vector3f(roi/2,roi/2,lut.h/2));
	ApplyPoissonNoise(tmp, maxval);

	std::string fn = SPrintf( "sb_area_roi%d_scan%d_steps%d_qit%d_N%d", roi, (int)scan_width, steps, qi_it, samples);
	WriteJPEGFile( (fn + ".jpg").c_str(), tmp);
	tmp.free();

	fn += ".txt";
	for (int y=0;y<steps;y++)  {
		for (int x=0;x<steps;x++)
		{
			vector3f cpos( (x+0.5f-steps/2) * dx, (y+0.5f-steps/2) * dx, 0 );

			cfg.qi_iterations = qi_it;
			auto r= AccBiasTest(orglut, &trk, samples, cpos+ct, vector3f(), 0, maxval, qi_it < 0 ? LT_XCor1D : 0);
			
			float row[] = { r.acc.x, r.acc.y, r.acc.z, r.bias.x, r.bias.y, r.bias.z,  r.crlb.x, r.crlb.z, samples };
			WriteArrayAsCSVRow(fn.c_str(), row, 9, x+y>0);

			dbgprintf("X=%d,Y=%d\n", x,y);
		}
	}
	orglut.free();
	lut.free();
}
Exemple #17
0
CfgValue* CfgValue::ParseValue (InputBuffer& buf)
{
	CfgValue *v = 0;

	if (buf.skipWhitespace ())
		buf.expecting ("Value");

	// parse value types:
	int token = nextToken (buf);

	switch (token) {
		case CT_LIST:
			v = new CfgList();
			break;
		case CT_NUMERIC:
			v = new CfgNumeric();
			break;
		case CT_LITERAL:
			v = new CfgLiteral();
			break;
		case CT_COMMAND: {
			++buf;
			std::string cmd = buf.parseIdent();
			d_trace("Cmd: %s\n", cmd.c_str());
			if (cmd == "include") {
				return LoadNestedFile(buf);
			} else {
				throw ContentException(SPrintf("%s. Unknown command: %s", buf.location().c_str() ,cmd.c_str()));
			}
		}
		case CT_IDENT:
			throw ContentException(buf.location() + SPrintf("Unexpected identifier: '%s'", buf.parseIdent()) );
	}

	if (v) {
		try {
			v->Parse(buf);
			v->cfgFilePath = buf.filename;
		} catch(const ContentException& e) {
			delete v;
			throw e;
		}
	}
	return v;
}
Exemple #18
0
void EditorUI::ConvertToS3O()
{
	static int texW = 256;
	static int texH = 256;
	
	texW = atoi (fltk::input ("Enter texture width: ", SPrintf("%d", texW).c_str()));
	texH = atoi (fltk::input ("Enter texture height: ", SPrintf("%d", texH).c_str()));
	std::string name_ext = fltk::filename_name (filename.c_str());
	std::string name (name_ext.c_str(), fltk::filename_ext (name_ext.c_str()));
	if (model->ConvertToS3O(GetFilePath(filename) + "/" + name + "_tex.bmp", texW, texH)) {
		// Update the UI
		SetModelTexture (0, model->texBindings[0].texture.Get());
		SetMapping (MAPPING_S3O);
		BACKUP_POINT("Converted to S3O texturing");
	} else
		BackupManager::Get().ReloadLast ();
	Update();
}
Exemple #19
0
void TestFourierLUTOnDataset()
{
	const char*basepath= "D:/jcnossen1/datasets/RefBeads 2013-09-02/2013-09-02/";

	process_bead_dir(SPrintf("%s/%s", basepath, "tmp_001").c_str(), 80, [&] (ImageData *img, int bead, int frame) {
		


	}, 1000);
}
Exemple #20
0
/// #ref : http://serious-code.net/moin.cgi/MiniDump
tstring GetFaultReason(PEXCEPTION_POINTERS exPtrs)
{
    if (::IsBadReadPtr(exPtrs, sizeof(EXCEPTION_POINTERS))) 
        return _T("bad exception pointers");

    // 간단한 에러 코드라면 그냥 변환할 수 있다.
    switch (exPtrs->ExceptionRecord->ExceptionCode)
    {
    case EXCEPTION_ACCESS_VIOLATION:         return _T("EXCEPTION_ACCESS_VIOLATION");
    case EXCEPTION_DATATYPE_MISALIGNMENT:    return _T("EXCEPTION_DATATYPE_MISALIGNMENT");
    case EXCEPTION_BREAKPOINT:               return _T("EXCEPTION_BREAKPOINT");
    case EXCEPTION_SINGLE_STEP:              return _T("EXCEPTION_SINGLE_STEP");
    case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:    return _T("EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
    case EXCEPTION_FLT_DENORMAL_OPERAND:     return _T("EXCEPTION_FLT_DENORMAL_OPERAND");
    case EXCEPTION_FLT_DIVIDE_BY_ZERO:       return _T("EXCEPTION_FLT_DIVIDE_BY_ZERO");
    case EXCEPTION_FLT_INEXACT_RESULT:       return _T("EXCEPTION_FLT_INEXACT_RESULT");
    case EXCEPTION_FLT_INVALID_OPERATION:    return _T("EXCEPTION_FLT_INVALID_OPERATION");
    case EXCEPTION_FLT_OVERFLOW:             return _T("EXCEPTION_FLT_OVERFLOW");
    case EXCEPTION_FLT_STACK_CHECK:          return _T("EXCEPTION_FLT_STACK_CHECK");
    case EXCEPTION_FLT_UNDERFLOW:            return _T("EXCEPTION_FLT_UNDERFLOW");
    case EXCEPTION_INT_DIVIDE_BY_ZERO:       return _T("EXCEPTION_INT_DIVIDE_BY_ZERO");
    case EXCEPTION_INT_OVERFLOW:             return _T("EXCEPTION_INT_OVERFLOW");
    case EXCEPTION_PRIV_INSTRUCTION:         return _T("EXCEPTION_PRIV_INSTRUCTION");
    case EXCEPTION_IN_PAGE_ERROR:            return _T("EXCEPTION_IN_PAGE_ERROR");
    case EXCEPTION_ILLEGAL_INSTRUCTION:      return _T("EXCEPTION_ILLEGAL_INSTRUCTION");
    case EXCEPTION_NONCONTINUABLE_EXCEPTION: return _T("EXCEPTION_NONCONTINUABLE_EXCEPTION");
    case EXCEPTION_STACK_OVERFLOW:           return _T("EXCEPTION_STACK_OVERFLOW");
    case EXCEPTION_INVALID_DISPOSITION:      return _T("EXCEPTION_INVALID_DISPOSITION");
    case EXCEPTION_GUARD_PAGE:               return _T("EXCEPTION_GUARD_PAGE");
    case EXCEPTION_INVALID_HANDLE:           return _T("EXCEPTION_INVALID_HANDLE");
        //case EXCEPTION_POSSIBLE_DEADLOCK:        return _T("EXCEPTION_POSSIBLE_DEADLOCK");
    case CONTROL_C_EXIT:                     return _T("CONTROL_C_EXIT");
    case 0xE06D7363:                         return _T("Microsoft C++ Exception");
    default:
        break;
    }

    // 뭔가 좀 더 복잡한 에러라면...
    static TCHAR szFaultReason[2048];
    SPrintf(szFaultReason, 2048, _T("Unknown")); 
    ::FormatMessage(
        FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS,
        ::GetModuleHandle(_T("ntdll.dll")),
        exPtrs->ExceptionRecord->ExceptionCode, 
        0,
        szFaultReason,
        0,
        NULL);

    return szFaultReason;
}
Exemple #21
0
int main(void)
{
    char buf[0x80]; /* storage for keeping the SPrintf result string */
    ULONG args[2];  /* storage for keeping the SPrintf arguments */

    args[0] = (ULONG) "result";
    args[1] = (ULONG) "PUTCHARPROTO macro";

    SPrintf("I am the %s of using SPrintf() with the new %s!", buf, args);

    printf("%s\n", buf); /* just a simple printf to output and add the \n */

return( 0);
}
Exemple #22
0
void TestZRangeBias(const char *name, const char *lutfile, bool normProf)
{
	ImageData lut = ReadLUTFile(lutfile);

	QTrkComputedConfig settings;
	settings.width=settings.height=100;
	settings.Update();
	ImageData img=ImageData::alloc(settings.width,settings.height);

	CPUTracker trk(settings.width,settings.height);
	NormalizeZLUT(lut.data, 1, lut.h, lut.w);
	trk.SetRadialZLUT(lut.data, lut.h, lut.w, 1, 1, settings.qi_maxradius, true, false);
	float* prof= ALLOCA_ARRAY(float,lut.w);

	int N=1000;
	std::vector< vector2f> results (N);
	for (int i=0;i<N;i++) {
		vector3f pos (settings.width/2, settings.height/2, i/(float)N*lut.h);
		GenerateImageFromLUT(&img, &lut, 1, settings.qi_maxradius, pos);
		if(InDebugMode&&i==0){
			WriteJPEGFile(SPrintf("%s-smp.jpg",name).c_str(),img);
		}

		trk.SetImageFloat(img.data);
		//trk.ComputeRadialProfile(prof,lut.w,settings.zlut_angularsteps, settings.zlut_minradius, settings.zlut_maxradius, pos.xy(), false);
		//float z=trk.LUTProfileCompare(prof, 0, 0, normProf ? CPUTracker::LUTProfMaxSplineFit : CPUTracker::LUTProfMaxQuadraticFit); result: splines no go!
		float z = trk.ComputeZ(pos.xy(), settings.zlut_angularsteps, 0, 0, 0, 0,true);
		results[i].x = pos.z;
		results[i].y = z-pos.z;
	}

	WriteImageAsCSV(SPrintf("%s-results.txt", name).c_str(),(float*) &results[0], 2, N);

	lut.free();
	img.free();
}
Exemple #23
0
void InputBuffer::skipKeyword (const char *kw)
{
	skipWhitespace();

	int a=0;
	while (!end() && kw[a])
	{
		if (get() != kw[a])
			break;
		next(), ++a;
	}

	if (kw[a])
		throw ContentException(SPrintf("%s: Expecting keyword %s\n", location().c_str(), kw));
}
Exemple #24
0
std::string InputBuffer::parseIdent ()
{
	std::string name;

	if(isalnum (get()))
	{
		name += get();
		for (next(); isalnum (get()) || get() == '_' || get() == '-'; next())
			name += get();

		return name;
	}
	else
		throw ContentException(SPrintf("%s: Expecting an identifier instead of '%c'\n", location().c_str(), get()));
}
Exemple #25
0
void WriteTrace(std::string filename, vector3f* results, int nResults)
{
	FILE *f = fopen(filename.c_str(), "w");

	if (!f) {
		throw std::runtime_error(SPrintf("Can't open %s", filename.c_str()));
	}

	for (int i=0;i<nResults;i++)
	{
		fprintf(f, "%.7f\t%.7f\t%.7f\n", results[i].x, results[i].y, results[i].z);
	}

	fclose(f);
}
Exemple #26
0
/// Make dump file name
tstring GetDumpFilename()
{
	TCHAR szFilename[_MAX_PATH];

	for ( int i=0; i<100; ++i )
	{
		SPrintf(szFilename, _MAX_PATH, TEXT("C:\\ZViewer%s_%d.dmp"), g_strVersion.c_str(), i);

		if ( 0 != _taccess(szFilename, 00) )	///< file not exist
		{
			break;
		}
	}
	tstring strDumpFilename = szFilename;
	return strDumpFilename;
}
Exemple #27
0
void CPUTracker::ComputeQuadrantProfile(scalar_t* dst, int radialSteps, int angularSteps,
				int quadrant, float minRadius, float maxRadius, vector2f center ,float* radialWeights)
{
	const int qmat[] = {
		1, 1,
		-1, 1,
		-1, -1,
		1, -1 };
	int mx = qmat[2*quadrant+0];
	int my = qmat[2*quadrant+1];

	if (angularSteps < MIN_RADPROFILE_SMP_COUNT)
		angularSteps = MIN_RADPROFILE_SMP_COUNT;

	for (int i=0;i<radialSteps;i++)
		dst[i]=0.0f;

	scalar_t total = 0.0f;
	scalar_t rstep = (maxRadius - minRadius) / radialSteps;
	for (int i=0;i<radialSteps; i++) {
		scalar_t sum = 0.0f;
		scalar_t r = minRadius + rstep * i;

		int nPixels = 0;
		scalar_t angstepf = (scalar_t) quadrantDirs.size() / angularSteps;
		for (int a=0;a<angularSteps;a++) {
			int i = (int)angstepf * a;
			scalar_t x = center.x + mx*quadrantDirs[i].x * r;
			scalar_t y = center.y + my*quadrantDirs[i].y * r;

			bool outside;
			scalar_t v = Interpolate(srcImage,width,height, x,y, &outside);
			if (!outside) {
				sum += v;
				nPixels++;
				MARKPIXELI(x,y);
			}
		}

		dst[i] = nPixels>=MIN_RADPROFILE_SMP_COUNT ? sum/nPixels : mean;
		if (radialWeights) dst[i] *= radialWeights[i];
		total += dst[i];
	}
	#ifdef QI_DBG_EXPORT
	WriteImageAsCSV(SPrintf("qprof%d.txt", quadrant).c_str(), dst, 1, radialSteps);
	#endif
}
Exemple #28
0
std::vector<uchar> ReadToByteBuffer(const char *filename)
{
	FILE *f = fopen(filename, "rb");

	if (!f)
		throw std::runtime_error(SPrintf("%s was not found", filename));

	fseek(f, 0, SEEK_END);
	int len = ftell(f);
	fseek(f, 0, SEEK_SET);

	std::vector<uchar> buf(len);
	fread(&buf[0], 1,len, f);

	fclose(f);
	return buf;
}
Exemple #29
0
LRESULT CALLBACK AboutWndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
  switch(iMessage)
  {
    case WM_CREATE:
    {
      int y = 20;
      TCHAR szTemp[MAX_PATH];

      SPrintf(szTemp, MAX_PATH, TEXT("ZViewer Version : %s"), g_strVersion.c_str());
      CreateLabel(hWnd, szTemp, y);

      y += 20;

      SPrintf(szTemp, MAX_PATH, TEXT("CacheHitRate : %d%%"), CacheManager::GetInstance().GetCacheHitRate());
      CreateLabel(hWnd, szTemp, y);

      NUMBERFMT nFmt = { 0, 0, 3, TEXT("."), TEXT(","), 1 };

      TCHAR szOUT[20];
      SPrintf(szTemp, MAX_PATH, TEXT("%d"), CacheManager::GetInstance().GetCachedKByte());
      ::GetNumberFormat((LCID)NULL, (DWORD)NULL, szTemp, &nFmt, szOUT, 20);

      SPrintf(szTemp, MAX_PATH, TEXT("CachedMemory : %sKB, Num of Cached Image : %u"), szOUT, static_cast<unsigned int>(CacheManager::GetInstance().GetNumOfCacheImage()));
      CreateLabel(hWnd, szTemp, y);

      SPrintf(szTemp, MAX_PATH, TEXT("ProgramPath : %s"), GetProgramFolder().c_str());
      CreateLabel(hWnd, szTemp, y);

      SPrintf(szTemp, MAX_PATH, TEXT("Library Version : %s"), ZImage::GetLibraryVersion().c_str());
      CreateLabel(hWnd, szTemp, y);

      y += 20;

      SPrintf(szTemp, MAX_PATH, TEXT("Homepage : http://zviewer.wimy.com/"));
      CreateLabel(hWnd, szTemp, y);
    }
    return TRUE;

    case WM_DESTROY:
    {
      EnableWindow( ZMain::GetInstance().GetHWND(), TRUE );
      break;
    }
  }
  return (DefWindowProc(hWnd, iMessage, wParam, lParam));
}
Exemple #30
0
static int nextToken (InputBuffer& buf) {
	buf.skipWhitespace();

	char r = *buf;
	if (r == '@')  // special command
		return CT_COMMAND;
	else if(isalpha (r))
		return CT_IDENT;
	else if(isdigit (r) || r == '.' || r == '-')
		return CT_NUMERIC;
	else if(r == '"')
		return CT_LITERAL;
	else if(r == '{')
		return CT_LIST;
	else if(r == ',')
		return CT_COMMA;

	throw ContentException(SPrintf("Unexpected character '%c'. ", r) + buf.location());
}