Пример #1
0
int _tmain(int argc, _TCHAR* argv[])
{
	//int i;
	//printf("argc: %d\n", argc);
	//for(i = 0; i < argc; i++)
	//	printf("arg %d: %S\n", i, argv[i]);
	if(argc != 4)
		usage();
	printf("reading %S to buffer...", argv[1]);
	deffile = loadFileToBuf(argv[1], &deflen);
	if((deffile != NULL)&&(deflen != 0))
	{
		printf("read 0x%x bytes OK\n", deflen);
		printf("reading %S to buffer...", argv[2]);
		listfile = loadFileToBuf(argv[2], &listlen);
		if((listfile != NULL)&&(listlen != 0))
		{
			printf("read 0x%x bytes OK\n", listlen);
			processFiles(argv[3]);
		}
	}
	if(deffile)
		free(deffile);
	if(listfile)
		free(listfile);
	printf("\n\n");
	return 0;
}
MBOOL
Mhal_facebeauty::
createFullFrame(IMEM_BUF_INFO Srcbufinfo)
{
    MBOOL  ret = MTRUE;
    MINT32 err = 0;
    CPTLog(Event_FBShot_createFullFrame, CPTFlagStart);
    MY_LOGD("[createFullFrame] + \n");
    NSCamShot::ISingleShot *pSingleShot = NSCamShot::ISingleShot::createInstance(eShotMode_FaceBeautyShot, "FaceBeautyshot");
    //
    pSingleShot->init();
    EImageFormat ePostViewFmt = static_cast<EImageFormat>(android::MtkCamUtils::FmtUtils::queryImageioFormat(mShotParam.ms8PostviewDisplayFormat)); 

    ImgBufInfo rSrcImgInfo;

    rSrcImgInfo.u4ImgWidth = mu4W_yuv;
    rSrcImgInfo.u4ImgHeight = mu4H_yuv;
    rSrcImgInfo.eImgFmt = eImgFmt_YV16;    
    rSrcImgInfo.u4Stride[0] = rSrcImgInfo.u4ImgWidth;
    rSrcImgInfo.u4Stride[1] = rSrcImgInfo.u4ImgWidth >> 1;
    rSrcImgInfo.u4Stride[2] = rSrcImgInfo.u4ImgWidth >> 1;
    rSrcImgInfo.u4BufSize = Srcbufinfo.size;
    rSrcImgInfo.u4BufVA = Srcbufinfo.virtAddr;
    rSrcImgInfo.u4BufPA = Srcbufinfo.phyAddr;
    rSrcImgInfo.i4MemID = Srcbufinfo.memID;
    pSingleShot->registerImgBufInfo(ECamShot_BUF_TYPE_YUV, rSrcImgInfo);

    ImgBufInfo rPostImgInfo;
    rPostImgInfo.u4ImgWidth = mShotParam.mi4PostviewWidth;
    rPostImgInfo.u4ImgHeight = mShotParam.mi4PostviewHeight;                   
    rPostImgInfo.eImgFmt = ePostViewFmt;
    rPostImgInfo.u4Stride[0] = rPostImgInfo.u4ImgWidth;
    rPostImgInfo.u4Stride[1] = rPostImgInfo.u4ImgWidth >> 1;
    rPostImgInfo.u4Stride[2] = rPostImgInfo.u4ImgWidth >> 1;
    // using blurimg buffer for reduce buffer size
    rPostImgInfo.u4BufSize = mpBlurImg.size;
    rPostImgInfo.u4BufVA = mpBlurImg.virtAddr;
    rPostImgInfo.u4BufPA = mpBlurImg.phyAddr;
    rPostImgInfo.i4MemID = mpBlurImg.memID;

    pSingleShot->registerImgBufInfo(ECamShot_BUF_TYPE_POSTVIEW, rPostImgInfo);
    
    //
        
    pSingleShot->enableDataMsg(ECamShot_DATA_MSG_YUV
                                 //| ECamShot_DATA_MSG_JPEG
                                 );
    pSingleShot->enableNotifyMsg(NSCamShot::ECamShot_NOTIFY_MSG_EOF);
    // shot param
    NSCamShot::ShotParam rShotParam(eImgFmt_YV16,         //yuv format
                         mShotParam.mi4PictureWidth,      //picutre width
                         mShotParam.mi4PictureHeight,     //picture height
                         0,                               //picture rotation in jpg
                         0,                               //picture flip
                         ePostViewFmt,
                         mShotParam.mi4PostviewWidth,      //postview width
                         mShotParam.mi4PostviewHeight,     //postview height
                         0,                                //postview rotation
                         0,                                //postview flip
                         mShotParam.mu4ZoomRatio           //zoom
                        );

    // jpeg param
    NSCamShot::JpegParam rJpegParam(mJpegParam.mu4JpegQuality,       //Quality
                         MTRUE                            //isSOI
                        );


    // sensor param
        NSCamShot::SensorParam rSensorParam(static_cast<MUINT32>(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId())),                             //Device ID 

#warning [FIXME] workaround for Alta phone capture mode can not work 
                             ACDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG,         //Scenaio 
                             //ACDK_SCENARIO_ID_CAMERA_PREVIEW,         //Scenaio 
                             10,                                       //bit depth 
                             MFALSE,                                   //bypass delay
                             MFALSE                                   //bypass scenario
                            );
    //
    pSingleShot->setCallbacks(fgCamShotNotifyCb, fgCamShotDataCb, this);
    //
    pSingleShot->setShotParam(rShotParam);

    //
    pSingleShot->setJpegParam(rJpegParam);

    //
    pSingleShot->startOne(rSensorParam);

    //
    pSingleShot->uninit();

    //
    pSingleShot->destroyInstance();
    
    if(mShotParam.ms8ShotFileName.string()!=NULL)
    {
        ret = createFBJpegImg(Srcbufinfo,mu4W_yuv,mu4H_yuv,1);
        if  ( ! ret )
        {
            goto lbExit;
        }
    }
    #ifdef Debug_Mode     
    loadFileToBuf("/data/FBSOURCE.yuv",(uint8_t*)Srcbufinfo.virtAddr,Srcbufinfo.size);   
    saveBufToFile("/sdcard/img.yuv", (uint8_t*)Srcbufinfo.virtAddr, Srcbufinfo.size); 
    #endif
    CPTLog(Event_FBShot_createFullFrame, CPTFlagEnd);
    MY_LOGD("[createFullFrame] - \n");
lbExit:
    return  ret;
}
Пример #3
0
int main()
{
	//learning rate
	double alpha = 0.03;
	int maxIter = 15000;
	int miniBatchSize = 1000;
	double noiseRatio = 0.3;
	int inputSize = 28*28;
	int hiddenSize = 28;
	int imgWidth = 8; 
	char *fileBuf  = new char[4096];
	bool ret = loadFileToBuf("ParamConfig.ini",fileBuf,4096);
	if(ret)
	{
		getConfigDoubleValue(fileBuf,"noiseRatio:",noiseRatio);
		getConfigDoubleValue(fileBuf,"alpha:",alpha);
		getConfigIntValue(fileBuf,"maxIter:",maxIter);
		getConfigIntValue(fileBuf,"miniBatchSize:",miniBatchSize);
		getConfigIntValue(fileBuf,"hiddenSize:",hiddenSize);
		getConfigIntValue(fileBuf,"inputSize:",inputSize);
		getConfigIntValue(fileBuf,"imgWidth:",imgWidth);
		cout << "noiseRatio:" << noiseRatio << endl;
		cout << "alpha:" << alpha << endl;
		cout << "maxIter:" << maxIter << endl;
		cout << "miniBatchSize:" << miniBatchSize << endl;
		cout << "hiddenSize:" << hiddenSize << endl;
		cout << "inputSize:" << inputSize << endl;
		cout << "imgWidth:" << imgWidth << endl;
	}
	delete []fileBuf;

	//set eigen threads
	SYSTEM_INFO info;
	GetSystemInfo(&info);
	Eigen::setNbThreads(info.dwNumberOfProcessors);

	MatrixXd trainData(1,inputSize);
	DAE dae(inputSize,hiddenSize);
	ret = loadMnistData(trainData,"mnist\\train-images-idx3-ubyte");
	cout << "Loading training data..." << endl;
	if(ret == false)
	{
		return -1;
	}
	clock_t start = clock();
	//cout << trainData.rows() << " " << trainData.cols() << endl; 
	MatrixXd showImage = trainData.leftCols(100).transpose();
	buildImage(showImage,imgWidth,"data.jpg");
	dae.train(trainData,noiseRatio,alpha,maxIter,miniBatchSize);
	cout << "End Train" << endl;
	MatrixXd hiddenTheta = dae.getTheta();
	buildImage(hiddenTheta,imgWidth,"weights.jpg",true);
	cout << "Saving hidden neurons" << endl;
	dae.saveModel("DAE_Model.txt");
	clock_t end = clock();
	cout << "The code ran for " << (end - start)/(double)(CLOCKS_PER_SEC*60)
		<< " minutes on " << Eigen::nbThreads() << " thread(s)." << endl;
	cout << "noiseRatio: " << noiseRatio << endl;
	cout << "alpha: " << alpha << endl;
	cout << "miniBatchSize: " << miniBatchSize << endl;
	system("pause");
	return 0;
}