⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tskprocess.c

📁 基于DSP SEED-DTK_VPM642实验箱的视频运动检测
💻 C
字号:
/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
#include <std.h>
#include <stdio.h>
#include <csl.h>
#include <csl_cache.h>
#include <csl_dat.h>
#include <chan.h>
#include <scom.h>
#include <utl.h>
#include "fvid.h"
#include "appmain.h"
#include "appThreads.h"
#include "tskProcess.h"

ScomBufChannels MsgProcess;

unsigned char t1[720*576],t2[720*576],t3[720*576],t4[720*576];
unsigned char SobelData[720*576*2];

void tskProcessInit()
{
	tskVideoInputInit();
    tskVideoOutputInit();                
}                   

/*-------------------------------------------------------*/
/* Create the channel instance : the cell algorithms will*/
/* be instantiated                                       */
/*-------------------------------------------------------*/
void tskProcessStart() 
{
	tskVideoInputStart();
    tskVideoOutputStart();
}


/*-------------------------------------------------------*/
/* The task will handle the processing part :            */
/* -Will get the message from the Input task with input  */
/*  frame pointers                                       */
/* -Will execute the channel to encode followed by decode*/
/* -Will pass the decoded frame pointers to output task  */
/*-------------------------------------------------------*/

void tskProcess()
{
    ScomBufChannels *pMsgBuf;            
    unsigned char *Input;
    int i,q,a,b,c,d,x,y;
    int flag=1;
    SCOM_Handle fromInputtoProc,fromProctoInput,\
    		fromProctoOut, fromOuttoProc;
    		
    fromInputtoProc = SCOM_open("INTOPROC");
    fromProctoInput = SCOM_open("PROCTOIN");
    fromProctoOut   = SCOM_open("PROCTOOUT");
    fromOuttoProc 	= SCOM_open("OUTTOPROC");
    
    while(1)
    {
 	    /*-----------------------------------------------------------*/
	  	/* Wait for the message from  input task to recieve captured */
  		/* frame to be cycled through encoding and decoding.         */
   		/*-----------------------------------------------------------*/
	 	pMsgBuf = SCOM_getMsg(fromInputtoProc, SYS_FOREVER); 
	 
	 	Input = pMsgBuf->bufChannel;
	    
	    /*-------------------------------------------------------*/
		/* motiontest								           	 */
		/*-------------------------------------------------------*/
		if(flag==1)
		{
			for(a=0;a<288;a++)  //1/4压缩的前帧
	  		{
		  	  	for(b=0;b<360;b++)
		  	  	{
		  	    	i=Input[2*a*720+2*b];
			  	    q=Input[2*a*720+2*b+1];
			  	    c=Input[(2*a+1)*720+2*b];
			  	    d=Input[(2*a+1)*720+2*b+1];
			  	    t1[a*360+b]=(i+q+c+d)>>2;
	  	  		}
	  		}
	  		flag=0;
	    	SCOM_putMsg(fromProctoInput, NULL); 
	    	continue;
	  	}
	  	for(a=0;a<288;a++)  //1/4压缩的前帧
	  	{
		  	 for(b=0;b<360;b++)
		  	 {
			  	    i=Input[2*a*720+2*b];
			  	    q=Input[2*a*720+2*b+1];
			  	    c=Input[(2*a+1)*720+2*b];
			  	    d=Input[(2*a+1)*720+2*b+1];
			  	    t2[a*360+b]=(i+q+c+d)>>2;
		  	  }
	  	
	  	}
	  	for(i=0;i<0x19500;i++)
		{				
			a=t1[i];
			b=t2[i];
					
	        if((a-b<0x40)&&(a-b>-0x40))   
	        {
	            t3[i]=0x00;
	        }
	        else
	        {
	            t3[i]=0xff;  
	        }    
	    }
	  	  
	  	for(i=0;i<287;i++)
	  	{
	  	    for(q=0;q<359;q++)
	  	    {
		  	    x=t3[i*360+q]-t3[(i+1)*360+q+1];
		  	    y=t3[(i+1)*360+q]-t3[i*360+q+1];
		  	    if(x<0){x=-x;}
		  	    if(y<0){y=-y;}
		  	    if(x+y>10)  //????????
		  	    t4[i*360+q]=0xff;
		  	    else
		  	    t4[i*360+q]=0x00;
	  	    }
	  	}    
	  	for(a=0;a<288;a++)  
	  	{
		  	  for(b=0;b<360;b++)
		  	  {
		  	    i=t4[a*360+b];
		  	    SobelData[2*a*720+2*b]=i;
		  	    SobelData[2*a*720+2*b+1]=i;
		  	    SobelData[(2*a+1)*720+2*b]=i;
		  	    SobelData[(2*a+1)*720+2*b+1]=i;
		        SobelData[0x32a00+2*a*720+2*b]=i;
		  	    SobelData[0x32a00+2*a*720+2*b+1]=i;
		  	    SobelData[0x32a00+(2*a+1)*720+2*b]=i;
		  	    SobelData[0x32a00+(2*a+1)*720+2*b+1]=i;
		  	  }	
	  	}
	    flag=1;
	    
	   	/*-----------------------------------------------------------*/
	   	/* Send the message to the input task to continue with next frame*/
	   	/*-----------------------------------------------------------*/
	    SCOM_putMsg(fromProctoInput, NULL);  	   	
	   		
	   	/*-----------------------------------------------------------*/
	   	/* Send message to output task with pointers to decoded frame*/
	   	/*-----------------------------------------------------------*/
	    MsgProcess.bufChannel = SobelData;
	   	SCOM_putMsg(fromProctoOut,&MsgProcess);
	   	
	   	/*-----------------------------------------------------------*/
	   	/* Waiting for display one frame is completed				 */
	   	/*-----------------------------------------------------------*/
	   	SCOM_getMsg(fromOuttoProc, SYS_FOREVER); 
 	}	                                                 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -