Example #1
0
void config_erodefilter(){
	XImage_filter_SetRows(&xErodeFilter, detailedTiming[currentResolution][V_ACTIVE_TIME]);
	XImage_filter_SetCols(&xErodeFilter, detailedTiming[currentResolution][H_ACTIVE_TIME]);
	//	XImage_filter_InterruptGlobalEnable(&xfilter);
	//	XImage_filter_InterruptEnable(&xfilter, 3);
	XImage_filter_EnableAutoRestart(&xErodeFilter);
	XImage_filter_Start(&xErodeFilter);
}
Example #2
0
int main()
{
        struct timespec time1,time2;
	
	cv::Mat inFrame; 
	inFrame = cv::imread("datalogger.jpg");	
	cvtColor(inFrame, inFrame, CV_RGB2GRAY);
	inFrame.convertTo(inFrame, CV_32SC1);

	cv::Mat hw_inputFrame;
	hw_inputFrame = inFrame;
	hw_inputFrame.data =(uchar *) setup_reserved_mem(INPUT_FRAME_ADDR);

	cv::Mat hw_outputFrame;
	hw_outputFrame = inFrame;
	hw_outputFrame.data = (uchar *) setup_reserved_mem(OUTPUT_FRAME_ADDR);

	inFrame.copyTo(hw_inputFrame);

        XImage_filter HLSDevice;
        HLSDevice = setup_ximage_filter(HLS_ADDR);
        XImage_filter_SetRows(&HLSDevice, inFrame.rows);
        XImage_filter_SetCols(&HLSDevice, inFrame.cols);

        xVDMA_info vdma;
        xVDMA_Init(&vdma, VDMABaseAddr, inFrame.cols, inFrame.rows, VDMAPixelWidth);

        clock_gettime(CLOCK_REALTIME, &time1);	

        	XImage_filter_Start(&HLSDevice); //Kick it to start it                  
        	xVDMA_kick(&vdma, INPUT_FRAME_ADDR, OUTPUT_FRAME_ADDR);
		while(!XImage_filter_IsDone(&HLSDevice)){}

        clock_gettime(CLOCK_REALTIME, &time2);

        std::cout << diff(time1, time2).tv_sec << ":" << diff(time1, time2).tv_nsec << std::endl;

        cv::Mat outFrame;
        hw_outputFrame.copyTo(outFrame);
	outFrame.convertTo(outFrame, CV_8UC1);
        imshow("output", outFrame);

		
while(1)
{	
	

        if (cv::waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
       {
            break;
       }
}

	return 0;
}
Example #3
0
void ChangeSobelMode(int newMode)
{
	static int currentStatus = -1;
	static int currentLiveMode = 0;
	struct xFilterConfig sobel_configuration;
	int fd_sobel = 0;
	//int fd_uio = 0;
	XImage_filter        xfilter;


	if (currentStatus == newMode && currentLiveMode == gLiveVideoOn)
		return;

	gActiveState = newMode;

	if (newMode != SOBEL_SW)
	{
		while(gSwSobelState != SW_SOBEL_STATE_OFF)
			sleep(1);
		DEBUG_Text ("Resetting all vdma\n");
		resetStop_VDMA_ALL();
		DEBUG_Text ("Resetting vdma done\n");

	}
	else
	{
		if (currentLiveMode != gLiveVideoOn && currentStatus == SOBEL_SW)
		{
			gActiveState = SOBEL_OFF;
			while(gSwSobelState != SW_SOBEL_STATE_OFF)
				sleep(1);
			gActiveState = newMode;
		}
		while(gSwSobelState != SW_SOBEL_STATE_ON)
			sleep(1);
	}

	currentLiveMode = gLiveVideoOn;

	if (newMode == SOBEL_HW)
	{
		// init sobel filer
		XImage_filter_Initialize(&xfilter, "FILTER");

		// init the configuration for sobel filter
		sobel_configuration.mode = E_xFilterContinousRunning;
		sobel_configuration.height = gVideoParam[gResolution][E_VActive];
		sobel_configuration.width = gVideoParam[gResolution][E_HActive];

		XImage_filter_SetRows(&xfilter, sobel_configuration.height);
		XImage_filter_SetCols(&xfilter, sobel_configuration.width);

		XImage_filter_InterruptGlobalEnable(&xfilter);
		XImage_filter_InterruptEnable(&xfilter, 3);
		XImage_filter_EnableAutoRestart(&xfilter);
		XImage_filter_Start(&xfilter);

		configureVDMA(VDMA_ID_TPG,DMA_DEV_TO_MEM,gLayerBase[SOBEL_LAYER]);
		startVDMA(VDMA_ID_TPG, DMA_DEV_TO_MEM);

		configureVDMA(VDMA_ID_SOBEL,DMA_DEV_TO_MEM,gLayerBase[DISPLAY_LAYER]);
		configureVDMA(VDMA_ID_SOBEL,DMA_MEM_TO_DEV,gLayerBase[SOBEL_LAYER]);

		startVDMA(VDMA_ID_SOBEL, DMA_DEV_TO_MEM);
		startVDMA(VDMA_ID_SOBEL, DMA_MEM_TO_DEV);

		XImage_filter_Release(&xfilter);
	}
	else if(newMode == SOBEL_OFF)
	{
		configureVDMA(VDMA_ID_TPG,DMA_DEV_TO_MEM,gLayerBase[DISPLAY_LAYER]);
		startVDMA(VDMA_ID_TPG, DMA_DEV_TO_MEM);

		DEBUG_Text ("TPG vdma configured\n");

		//open the sobel driver
		//if ((fd_sobel = open("/dev/xfilter", O_RDWR)) < 0)
		//	{
		//	printf("Cannot open device node xfilter\n");
		//	exit(1);
		//	}

		// STOP the sobel filter
		//if (ioctl(fd_sobel, XFILTER_STOP, NULL) < 0)
		//	{
		//	printf("Failed to initialize Sobel Filter driver\n");
		//	}

		//close(fd_sobel);
	}

	// might want to wait here if to activate sw sobel filter.
	currentStatus = newMode;
}