Ejemplo n.º 1
0
HRESULT CCapture::ConfigureCapture(const EncodingParameters& param)
{
    HRESULT hr = S_OK;
    DWORD sink_stream = 0;

    IMFMediaType *pType = NULL;

    hr = ConfigureSourceReader(m_pReader);

    if (SUCCEEDED(hr))
    {
        hr = m_pReader->GetCurrentMediaType(
            (DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 
            &pType
            );
    }

    if (SUCCEEDED(hr))
    {
        hr = ConfigureEncoder(param, pType, m_pWriter, &sink_stream);
    }


    if (SUCCEEDED(hr))
    {
        // Register the color converter DSP for this process, in the video 
        // processor category. This will enable the sink writer to enumerate
        // the color converter when the sink writer attempts to match the
        // media types.

        hr = MFTRegisterLocalByCLSID(
            __uuidof(CColorConvertDMO),
            MFT_CATEGORY_VIDEO_PROCESSOR,
            L"",
            MFT_ENUM_FLAG_SYNCMFT,
            0,
            NULL,
            0,
            NULL
            );
    }

    if (SUCCEEDED(hr))
    {
        hr = m_pWriter->SetInputMediaType(sink_stream, pType, NULL);
    }

    if (SUCCEEDED(hr))
    {
        hr = m_pWriter->BeginWriting();
    }

    SafeRelease(&pType);
    return hr;
}
void main(void)
{
    uint8_t *pFilledFrame   = NULL;
    uint8_t *pDisplayFrame  = NULL;
    bool     bDisplayEnabled = false;

    adi_initComponents(); /* auto-generated code */

    /* Adjust the core frequency */
    if (adi_pwr_Init (PROC_CLOCK_IN, PROC_MAX_CORE_CLOCK, PROC_MAX_SYS_CLOCK, PROC_MIN_VCO_CLOCK) != ADI_PWR_SUCCESS)
    {
        printf ("Failed to initialize Power service\n");
        return;
    }
    if(adi_pwr_SetFreq(PROC_REQ_CORE_CLOCK, PROC_REQ_SYS_CLOCK)!= ADI_PWR_SUCCESS )
    {
        printf ("Failed to initialize Power service\n");
        return;
    }

    /* Configure the Software controlled switches on BF609 EZ-Board */
    //ConfigSoftSwitches_BF609();
#if defined(VIDEOLOOPBACKYUV_720P)
    FINBOARD_CLK_Synth_Config_OUT4_74_25_MHz();
#else
    FINBOARD_CLK_Synth_Config_OUT4_27_00_MHz();
#endif
    FINBOARD_LED_Drivers_Init();
    FINBOARD_LED_Drivers_Config(1);

    /* Configure the sensor */
    if(ConfigureSensor() != SUCCESS)
    {
        printf("Failed to configure Sensor \n");
        return;
    }

    /* Configure the sensor for display */
    if(ConfigureEncoder() != SUCCESS)
    {
        printf("Failed to configure LCD \n");
        return;
    }
    FINBOARD_ADV7511_16bit_Mode();

    /* Submit the frame for filling */
    if(SubmitEmptyVideoFrame() != SUCCESS)
    {
        printf("Failed to submit empty video frame to the sensor \n");
        return;
    }

    /* Submit the next frame for filling */
    if(SubmitEmptyVideoFrame() != SUCCESS)
    {
        printf("Failed to submit empty video frame to the sensor \n");
        return;
    }

    /* Enable the sensor to capture the frames */
    if(EnableSensor(true) != SUCCESS)
    {
        printf("Failed to enable sensor \n");
        return;
    }

#if (EXAMPLE_TIMEOUT > 0)
    while(NumFilledFrames < EXAMPLE_TIMEOUT)
#else
    while(1)
#endif
    {
        /* Get filled frame from sensor */
        if(GetFilledVideoFrame(&pFilledFrame) != SUCCESS)
        {
            printf("Failed to get filled frame from the sensor \n");
            return;
        }

        if(pFilledFrame != NULL)
        {
            NumFilledFrames++;

            pDisplayFrame = pFilledFrame;

            /* Submit the next frame for filling */
            if(SubmitEmptyVideoFrame() != SUCCESS)
            {
                printf("Failed to submit empty video frame to the sensor \n");
                return;
            }

            if(bDisplayEnabled == false)
            {
                /* Submit the filled frame to encoder for display */
                if(DisplayFrame(pDisplayFrame) != SUCCESS)
                {
                    printf("Failed to submit the filled frame to LCD for display \n");
                    return;
                }
            }

            if(NumFilledFrames == 2)
            {
                /* Enable video display after submitting two frames */
                if(EnableDisplay(true) != SUCCESS)
                {
                    printf("Failed to enable video display \n");
                    return;
                }

                bDisplayEnabled = true;
            }
        }

        if(bDisplayEnabled == true)
        {
              uint8_t *pFrame;

              if(GetDisplayedFrame((void **)&pFrame) != SUCCESS)
              {
                  printf("Failed to get the displayed frame \n");
              }

              /* Submit the filled frame to the encoder for display */
              if(DisplayFrame(pDisplayFrame) != SUCCESS)
              {
                  printf("Failed to submit the filled frame to encoder for display \n");
                  return;
              }
          }
       }

   FINBOARD_LED_Drivers_Config(0);
    printf("All done \n");
}
Ejemplo n.º 3
0
void main(void)
{
    uint32_t nResult= SUCCESS;	
   /* Buffer pointer used to get the  frames with data */
    void *pVideoBuffer=NULL;
    uint32_t *pTemp = (uint32_t *)&buffer[0];
    //MT9M114_VIDEO_BUF *pBufTemp;
    //uint32_t       *pBuf;
    //int32_t        nSize;
   /* Initialize the ADI components such as pin muxing etc */
    adi_initComponents(); /* auto-generated code */
   /* Initialize  DMC */
    adi_DMCamInit();
   /* By default, Graphics is not used to draw the bounding rectangle around the detected dot */
    InitTitle((void*)(*pTemp));


    nBoundingRectFlag = 0;
#if defined(FINBOARD)
	nIllumination = prevIllumination = 1;
#endif
    /* Registering the MDMA callback for Channel-1(Dest) with Interrupt ID 91 (page 219, HRM)
     * to Core-B since it is used to mark the canny output */
    //nSize = sizeof(uint32_t);

    /******************************************************/


    /*mcapi_finalize(&mcapi_status);
    if (MCAPI_SUCCESS != mcapi_status) {
        exit(1);
    }*/
#ifdef DEBUG_INFO
    printf("[CORE A]: BF609_MCAPI_msg: %s\n", retVal == PASS ? "All done" : "Error...");
#endif
     /******************************************************/

    do
    {
			/* Initialize the power services*/
		if (adi_pwr_Init (PROC_CLOCK_IN, PROC_MAX_CORE_CLOCK, PROC_MAX_SYS_CLOCK, PROC_MIN_VCO_CLOCK) != ADI_PWR_SUCCESS)
		{
			printf ("Failed to initialize Power service\n");
			nResult= FAILURE;
			break;
		}
		 /* Set the required core clock and system clock */
		if(adi_pwr_SetFreq(PROC_REQ_CORE_CLOCK, PROC_REQ_SYS_CLOCK)!= ADI_PWR_SUCCESS )
		{
			printf ("Failed to initialize Power service\n");
			nResult= FAILURE;
			break;
		}
		/* Initialize the GPIO for enabling/disabling the PB1 which inturn control the graphics to
		   draw the  rectangle around the detected dots
		 */
		if(Init_GPIO()!= SUCCESS)
		{
			printf("\n GPIO initialization failed \n");
			nResult= FAILURE;
			break;
		}


#if !defined(FINBOARD)
		/* Configure the Software controlled switches on BF609 EZ-Board */
		ConfigSoftSwitches_BF609();
#else // !defined(FINBOARD)
		FINBOARD_CLK_Synth_Restore(); // restore firmware settings
		FINBOARD_LED_Drivers_Init();
		FINBOARD_LED_Drivers_Config( nIllumination );
#endif // defined(FINBOARD)

		/* Configure the sensor */
		if(ConfigureSensor() != SUCCESS)
		{
			printf("Failed to configure Sensor \n");
			nResult= FAILURE;
			break;
		}
		/* Configure the sensor for display */
		if(ConfigureEncoder() != SUCCESS)
		{
			printf("Failed to configure LCD \n");
			nResult= FAILURE;
			break;
		}

#if defined(FINBOARD)
		FINBOARD_ADV7511_16bit_Mode();
#endif

		/* Submit the first frame for filling */
		if(SubmitEmptyVideoFrame() != SUCCESS)
		{
			printf("Failed to submit empty video frame to the sensor \n");
			nResult= FAILURE;
			break;
		}

		/* Submit the second frame for filling */
		if(SubmitEmptyVideoFrame() != SUCCESS)
		{
			printf("Failed to submit empty video frame to the sensor \n");
			nResult= FAILURE;
			break;
		}
		/* Submit first buffer to encoder */
		if(SubmitEncBuf(pEncDispStartBuf) != SUCCESS)
		{
			printf("Failed to submit  video frame to the encoder \n");
			nResult= FAILURE;
			break;
		}
		/* Submit same buffer since we will be waiting for the first frame from the sensor */
		if(SubmitEncBuf(pEncDispStartBuf) != SUCCESS)
		{
			printf("Failed to submit  video frame to the encoder \n");
			nResult= FAILURE;
			break;
		}
		/* Wait till the first frame is captured */
		/* Enable the sensor to capture the frames */
		if(EnableDisplay(true) != SUCCESS)
				{
					printf("Failed to enable video encoder  \n");
					nResult= FAILURE;
					break;
				}
		if(EnableSensor(true) != SUCCESS)
				{
					printf("Failed to enable sensor \n");
					nResult= FAILURE;
					break;
				}
		/* Start the display */
		while( NumFramesCaptured == 0 );

    }while(0);

    printf( "\nVersion: %s-%s\n", __DATE__, __TIME__);

    /* A while loop to timeout the example*/
    while(NumFramesCaptured < EXAMPLE_TIMEOUT && nResult == SUCCESS )
    {
    	           /* Get the video display frame */
           pVideoBuffer = NULL;
           while(pVideoBuffer == NULL)
           {
               GetProcessedSensorBuf (&pVideoBuffer);
           }
           if(pVideoBuffer != NULL )
           {
#if defined(FINBOARD)
               if ( prevIllumination != nIllumination )
               {
            	  prevIllumination = nIllumination;
                  FINBOARD_LED_Drivers_Config( nIllumination );
               }
#endif
           }
           /* Increment the counter */
           NumFilledFrames++;
    }
    /* end of while loop */
    if(nResult == SUCCESS)
    {
         printf("All done \n");
    }
    else
    {
	 printf("Failed to run dot count application.\n");
    }
}