コード例 #1
0
ファイル: DisplayCanvas.cpp プロジェクト: pranphy/KittyWx
void DisplayCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
{
	SetCurrent();
	static bool OneTime = false;
	if(OneTime == false)
	{
		LoadAllImages();
		ShuffleCards();
		OneTime = true;
	}
    glClearColor(0.0f,0.5f,0.4f,0);
    glClear(GL_COLOR_BUFFER_BIT);
    //DrawTriangle();
    Render();
    glFlush();
    SwapBuffers();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: mereckaj/VisionAssignment2
/*
 * Magic happens here.
 */
int main() {
    cv::Mat detectedWhitePage, maskedImage, possibleBlueDotLocations, transformedImage;
    std::vector<cv::Point> approxCorners,detectedCorners, cornerPointDestinations, centresOfConnectedComponents;
    std::vector<std::vector<cv::Point>> connectedComponents, closestPoints;
    std::vector<cv::Vec4f> bestFitLines;
    int matchedImageIndex = 0;

    LoadAllImages();

    /*
     * Take a single book picture and find the top left, bottom left, bottom right, top right blue pixels
     * return a vector of those pixels and use them as destination points for transformations
     *
     * This should preserve the aspect ratio of the images
     */
    cornerPointDestinations = FindTemplateCorners(pageImages[0]);

    /*
     * Loop over every single image and perform some vision magic on each
     */
    for (size_t imageIndex = 0; imageIndex < groundTruth.size(); imageIndex++) {

        // Detect the white page, will tell the program to look for blue dots in that page
        PageDetector pageDetector(viewImages[imageIndex]);
        detectedWhitePage = pageDetector.DetectPage();

        // Apply the white page location as a mask to the original image.
        maskedImage = pageDetector.ApplyMask(viewImages[imageIndex], detectedWhitePage);
        Transformer transformer(maskedImage);

        // Search for blue spots in the masked image
        PointDetector pointDetector(maskedImage, MAGIC_THRESHOLD_VALUE, std::to_string(imageIndex));
        possibleBlueDotLocations = pointDetector.DetectPoints(backProjectSample[0]);
        connectedComponents = pointDetector.BlueDotsToContours(possibleBlueDotLocations);
        centresOfConnectedComponents = pointDetector.GetCentres(connectedComponents);
        approxCorners = transformer.FindApproximateCornersFromCentresOfComponents(centresOfConnectedComponents);
        closestPoints = transformer.FindClosestPoints(approxCorners, possibleBlueDotLocations);
        bestFitLines = transformer.LinesOfBestFit(closestPoints);

        // Find the approxCorners that were of the image
        detectedCorners = transformer.FindIntersections(maskedImage, bestFitLines);

        // Transform the image
        transformedImage = transformer.Transform(viewImages[imageIndex], detectedCorners, cornerPointDestinations);

        // Match the image with a template
        TemplateMatcher templateMatcher(transformedImage, pageImages, (int) pageFiles.size());
        matchedImageIndex = templateMatcher.Match();

        if(matchedImageIndex==-1){
            // No match found, since I only passed actual pages and it couldn't find it this is a Flase Negative
            FalseNegative++;
        }else {
            // Ground truth starts counting from 1 while program start counting from 0
            matchedImageIndex++;

            if (matchedImageIndex == groundTruth[imageIndex]) {
                TruePositive++;
            }else{
                FalsePositive++;
            }
        }
    }
    debugMessage("TP: " + std::to_string(TruePositive)+"/" + std::to_string(viewFiles.size()));
    debugMessage("FP: " + std::to_string(FalsePositive)+"/" + std::to_string(viewFiles.size()));
    debugMessage("TN: " + std::to_string(TrueNegative)+"/" + std::to_string(viewFiles.size()));
    debugMessage("FN: " + std::to_string(FalseNegative)+"/" + std::to_string(viewFiles.size()));
    return EXIT_SUCCESS;
}
コード例 #3
0
ファイル: BootMode.c プロジェクト: emuikernel/OBM
//////////////////////////////////////////////////////////////////////
// This is the entry point for the Boot Mode. 
//
// Inputs: Current TIM pointer, BootMode(SINGLE or DUAL)
// Outputs: Returns the next image that we will transfer the control to.
//
// It mainly functions as following depending on the BOOT MODE:
// 1) SINGLE TIM BOOT MODE:
//		a) Configures the Flashes and Initializes the Flash Management	
//		b) Loads (and validates) all the images using a loop.
//		c) If TRUSTED, provisions the platform before finishing
//		d) Returns the next image that we will transfer the control to. 
// 2) DUAL TIM BOOT MODE:
//		a) Configures the Flashes and Initializes the Flash Management
// 		b) Loads (and validates) the second TIM. 	
//		c) Configures the Flashes and Initializes the Flash Management 
//		   using the new TIM.
//		d) Loads (and validates) all the images using a loop.
//		e) If TRUSTED, provisions the platform before finishing
//      f) Returns the next image that we will transfer the control to.
//////////////////////////////////////////////////////////////////////
pIMAGE_INFO_3_4_0 BootModeMain(pTIM pTIM_h, OPERATING_MODE_T BootMode, pFUSE_SET pFuses)
{
    UINT_T Retval = NoError;
    pIMAGE_INFO_3_4_0 pBootImageInfo = NULL;
	UINT_T FlashNumber = 0;

	// Determine the Flash that will be used to store the downloaded images.
	FlashNumber = (pTIM_h->pConsTIM->FlashInfo.BootFlashSign) & 0xFF;
	
	Retval = Configure_Flashes (FlashNumber, BOOT_FLASH);
	if( Retval != NoError)
	   FatalError(Retval);
	
	//turn on the flash management
	InitializeFM(LEGACY_METHOD, BOOT_FLASH);

	// Fall through to SINGLE TIM Mode. 
	// Remember in both SINGLE and DUAL TIM Modes, we need to 
	// go through the SINGLE TIM Mode branch at the end. 

#if ZIMI_PB05
	UINT16_T vbat_mv;
	extern PowerUPType_t powerup;
	extern int isTempDetect;
	if(powerup == PowerUP_ONKEY)
	{
		UINT8_T m_boot;

		if(isTempDetect)
		{
			UINT8_T mm = check_BootONKey(10, 0);
			if(mm == 0)
			{
				serial_outstr("zimi# check onkey 10ms failed\n");
				System_poweroff();
			}
			bqTempDetect();   //here delay 500ms

			m_boot = check_BootONKey(1000, 0);
		}
		else
			m_boot = check_BootONKey(1, 1);
		if(m_boot == 0)
		{
			serial_outstr("zimi# check 3s onkey failed\n");
			System_poweroff();
		}
	}

	#if ZIMI_LED_MODE
	GetBatInstantVolt(&vbat_mv,USB_NotConnect);
	UINT8_T m_temp = IIC_read(0x07) & 0xff;

	if(3500<vbat_mv && vbat_mv<4050)
	{
		 m_temp |= 0x20;
		 IIC_write(0x07,m_temp);
		 Delay_us(300*1000);
		 GetBatInstantVolt(&vbat_mv,USB_NotConnect);
		 m_temp &= ~0x20;
		 IIC_write(0x07,m_temp);
	}
	else
	{
		GetBatInstantVolt(&vbat_mv,USB_NotConnect);
	}

	*(VUINT_T *)ZIMI_BATVOL_INIT_FLAG_ADDR = vbat_mv;

	if(vbat_mv<3600)
	{
		serial_outstr("zimi# bat led low\n");
		LED_BAT_R_ON();
	}
	else if(vbat_mv<3750)
	{
		serial_outstr("zimi# bat led middle\n");
		LED_BAT_R_ON();
		LED_BAT_G_ON();
	}
	else
	{
		serial_outstr("zimi# bat led high\n");
		LED_BAT_G_ON();
	}
	#else
	#if 0   //case: big/small system led: all green
	extern PowerUPType_t powerup;
	if(powerup != PowerUP_USB)
	{
		LED_WIFI_G_ON();
		LED_BAT_G_ON();
		LED_LTE_G_ON();
	}
	else  //xyl USB mode, we light BAT led only according to VBAT
	{
		if(vbat_mv<3650)
		{
			serial_outstr("zimi# bat led low\n");
			LED_BAT_R_ON();
		}
		else if(vbat_mv<3950)
		{
			serial_outstr("zimi# bat led middle\n");
			LED_BAT_R_ON();
			LED_BAT_G_ON();
		}
		else
		{
			serial_outstr("zimi# bat led high\n");
			LED_BAT_G_ON();
		}
	}
	#endif
	#endif
#endif

#if TR069_SUPPORT
	Retval = firmware_upgrade(pTIM_h);
	serial_outstr("TR069 return\n");
	serial_outnum(Retval);
	serial_outstr("\n");
	if (Retval == NoError)
	{
		PlatformSetTR069Flag();
		do_wdt_reset();
	}
	else
#endif
	{
	#if SILENT_RESET
		if (PlatformCheckSilentReset())
			pBootImageInfo = LoadSilentImages(pTIM_h);
		else
	#endif
	#if BACKUP_IMAGE
		if (back_image_key || upgrade_failed_flag || (PlatformCheckBackupImagesFlag() == 0x4D494E53))
			pBootImageInfo = LoadBackupImages(pTIM_h);
		else
	#endif

			pBootImageInfo = LoadAllImages(pTIM_h);
	}
									  				
    return pBootImageInfo;
}