亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? framemgr.c

?? he AVRcam source files were built using the WinAVR distribution (version 3.3.1 of GCC). I haven t t
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
    Copyright (C) 2004    John Orlando
    
   AVRcam: a small real-time image processing engine.

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public
    License along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

   For more information on the AVRcam, please contact:

   john@jrobot.net

   or go to www.jrobot.net for more details regarding the system.
*/
/*********************************************************
	Module Name: FrameMgr.c
	Module Date: 04/10/2004
	Module Auth: John Orlando
	
	Description: This modules is responsible for performing
	both medium and high level processing on image data.
	This is performed at both the line level as well as
	the frame level.  It controls the main flow of the
	system, adhering to all the critical timing 
	requirements (such as when serial data can be transferred,
	etc).
    
    Revision History:
    Date        Rel Ver.    Notes
    4/10/2004      0.1     Module created
    6/30/2004      1.0     Initial release for Circuit Cellar
                           contest.
    11/15/2004     1.2     Updated processLine() function so 
                           it will remove objects less than
                           a specified length/width (reduces
                           shot noise)
*********************************************************/

/*	Includes */
#include <stdlib.h>
#include <string.h>
#include <avr/io.h>
#include "Executive.h"
#include "UIMgr.h"
#include "FrameMgr.h"
#include "CamInterface.h"
#include "UartInterface.h"
#include "Utility.h"
#include "I2CInterface.h"
#include "CamConfig.h"
#include "CommonDefs.h"

/* 	Local Structures and Typedefs */
enum
{
	ST_FrameMgr_idle,
	ST_FrameMgr_TrackingFrame,
	ST_FrameMgr_DumpingFrame
};

typedef unsigned char FrameMgr_State_t;

/*  Definitions */
/* The most objects that can be tracked at any one time is 8.  
This number is determined by the number of bytes that can be
sent out during a frame (one byte per line, 144 lines per frame) 
with the number of bytes in a tracked object (7) + some wiggle
room :-) ... I guess this could be increased to around 20 if
we had enough room and cycles to process objects between lines */
#define MAX_TRACKED_OBJECTS	8

/* This defines the number of bytes that make up a trackedObject_t
structure... */
#define SIZE_OF_TRACKED_OBJECT 8

/* This define is used to turn off the timer overflow interrupt
that is generated when the PCLK overflows TIMER1 */
#define DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0xFB

/* This define is used to determine if a run length is too small
to be concerned with.  This helps to reduce the number of false
positives. */
#define MIN_OBJECT_TRACKING_WIDTH 3

/* This define is used to determine if an object has enough
height to be considered worth tracking...it is used to reduce
shot noise */
#define MIN_OBJECT_TRACKING_HEIGHT 3

/* This define is used to indicate how often the filter routine
that removes objects less than MIN_OBJECT_TRACKING_HEIGHT should
be executed.  It is measured in a number of lines (7 nominally). */
#define RUN_OBJECT_FILTER_MASK 0x07

/* This enum describes the possible colors that can
be tracked by the system.  This can't be represented as
simple color names (red, brown, etc) due to the fact that
the user sets which colors will be associated with which
bits.  Remember...after the AND operation of the indexed
color map values executes, either a single bit indicating
the color should be set, or no bits indicating that the
color isn't represented in the color map (notTracked). */
enum
{
	notTracked,
	color1,		/* bit 1 color */
	color2,		/* bit 2 color */
	color3,		/* bit 3 color */
	color4,		/* bit 4 color */
	color5,		/* bit 5 color */
	color6,		/* bit 6 color */
	color7,		/* bit 7 color */
	color8		/* bit 8 color */
};

typedef unsigned char trackedColor_t;

/* This structure defines the info that needs to be
maintained for each trackedObject in the trackingTable */
typedef struct
{
	trackedColor_t  color;
	unsigned char lastLineXStart;
	unsigned char lastLineXFinish;
	unsigned char x_upperLeft;
	unsigned char y_upperLeft;
	unsigned char x_lowerRight;
	unsigned char y_lowerRight;
	unsigned char objectValid;  /* used to be a fill byte...now it is
                                     used to determine if the object is valid
                                     or not...it gets invalidated if it is
                                     determined that it is too small, or
                                     that the object is within another object */
} trackedObject_t;

/* These defines are used to index into each individual element in the
trackedObject_t structure.  This seems to be MUCH more efficient than
accessing the elements in GCC. */
#define COLOR_OFFSET                0
#define LAST_LINE_X_START_OFFSET    1
#define LAST_LINE_X_FINISH_OFFSET   2
#define X_UPPER_LEFT_OFFSET         3
#define Y_UPPER_LEFT_OFFSET         4
#define X_LOWER_RIGHT_OFFSET        5
#define Y_LOWER_RIGHT_OFFSET        6
#define VALID_OBJECT_OFFSET         7

/*  Local Variables */
/* The trackedObjectTable is used to hold up to eight tracked objects
while they are being acquired. */
static trackedObject_t trackedObjectTable[MAX_TRACKED_OBJECTS];
static trackedObject_t *pCurrentTrackedObjectTable = trackedObjectTable;
static unsigned char lineCount = 0;
static FrameMgr_State_t currentState = ST_FrameMgr_idle;
static unsigned char numCurrTrackedObjects = 0;
static unsigned char numPrevTrackedObjects = 0;
static unsigned char trackedLineCount = 0;

/*  Local Functions  */
static void FrameMgr_findConnectedness(void);

/*  Extern Functions */
/* These functions are located in assembly files, and thus
must be externed here so they can be referenced in the source below. */
extern void CamIntAsm_waitForNewTrackingFrame(unsigned char *pBuffer, unsigned char *pMemLookup);
extern void CamIntAsm_waitForNewDumpFrame(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
extern void CamIntAsm_acquireTrackingLine(unsigned char *pBuffer, unsigned char *pMemLookup);
extern void CamIntAsm_acquireDumpLine(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);

/***********************************************************
	Function Name: FrameMgr_init
	Function Description: This function is responsible
	for initializing the FrameMgr.  This includes 
	setting up the various buffers and data needed to 
	process each frame of image data.
	Inputs:  none
	Outputs: none
***********************************************************/	
void FrameMgr_init(void)
{
	memset(trackedObjectTable,0x00,sizeof(trackedObjectTable));
}


/***********************************************************
	Function Name: FrameMgr_dispatchEvent
	Function Description: This function is responsible for
	taking an incoming event and performing the needed
	actions with it as pertains to the FrameMgr.
	Inputs:  event - the generated event
	Outputs: none
***********************************************************/	
void FrameMgr_dispatchEvent(unsigned char event)
{	
	switch(event)
	{
		case EV_DUMP_FRAME:
            /* try re-initializing the camera before we start dumping */
            
			CamConfig_setCamReg(0x11,0x01);  /* reduce the frame rate for dumping*/
			CamConfig_sendFifoCmds();
			Utility_delay(1000);		/* allow the new frame rate to settle */
			lineCount = 0;
			currentState = ST_FrameMgr_DumpingFrame;
			//CamIntAsm_waitForNewDumpFrame(currentLineBuffer,previousLineBuffer);
            FrameMgr_acquireLine();
			break;
		
		case EV_ENABLE_TRACKING:
			currentState = ST_FrameMgr_TrackingFrame;					
			FrameMgr_acquireFrame();
			break;
			
		case EV_ACQUIRE_FRAME_COMPLETE:
			FrameMgr_processFrame();
			break;
		
		case EV_PROCESS_FRAME_COMPLETE:
			FrameMgr_acquireFrame();
			break;

		case EV_SERIAL_DATA_RECEIVED:
			if (currentState != ST_FrameMgr_idle)
			{
				/* we need to go back to processing line data, since
				serial data reception interrupted us....just trash the
				frame and act like the frame has been processed, which
				will kick off the system to wait for the next line */
				PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
			}
			break;
			
		case EV_DISABLE_TRACKING:
			/* tracking needs to be turned off */
			currentState = ST_FrameMgr_idle;
			break;
	}
}

/***********************************************************
	Function Name: FrameMgr_acquireFrame
	Function Description: This function is responsible for
	beginning of the acquisition of a new frame of data
	from the camera interface. The acquisition of this line 
	depends on the current state of the FrameMgr.
	Inputs:  none
	Outputs: none
***********************************************************/	
void FrameMgr_acquireFrame(void)
{
	if (currentState == ST_FrameMgr_TrackingFrame)
	{
		trackedLineCount = 0;
		numPrevTrackedObjects = numCurrTrackedObjects;
		numCurrTrackedObjects = 0;
		
		/* clear out the tracking table, and wait for the new frame
		to start */
		memset(trackedObjectTable,0x00,sizeof(trackedObjectTable));
		//CamIntAsm_waitForNewTrackingFrame(currentLineBuffer,colorMap);
        WAIT_FOR_VSYNC_HIGH();
        CamIntAsm_acquireTrackingLine(currentLineBuffer,colorMap);
	}
}

/***********************************************************
	Function Name: FrameMgr_acquireLine
	Function Description: This function is responsible for
	acquiring a line of data from the camera interface.
	The acquisition of this line depends on the current
	state of the FrameMgr.
	Inputs:  none
	Outputs: none
***********************************************************/	
void FrameMgr_acquireLine(void)
{
	unsigned char tmpLineCount;
	
	/* clearing out the buffers takes too long...we should
	just overwrite the data here without a problem when
	we start acquiring...at no point do we check for 
	a 0x00 value in the current or previous lineBuffers,
	so it was a bit excessive :-)  */
	
	/* check which state we are in and proceed as needed */
	if (currentState == ST_FrameMgr_DumpingFrame)
	{
		tmpLineCount = lineCount*2;
        
        /* clearing out the line data in dump mode is ok, and actually
        is needed, since it is possible for the first dump line in
        a frame to come back with the last line captured of the
        last capture session...*/
        memset(currentLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
        memset(previousLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
		/* wait for another VSYNC so we know which frame to use 
		to start looking for a line to receive */
		WAIT_FOR_VSYNC_HIGH();  
		WAIT_FOR_VSYNC_LOW();
		
		/* look at lineCount to determine how many HREFs we should
		wait before we start sampling */
		while(tmpLineCount != 0)
		{
			WAIT_FOR_HREF_HIGH(); 
			tmpLineCount--;
			WAIT_FOR_HREF_LOW(); 
		}
		
		/*  we should now be ready to sample our line...*/
		CamIntAsm_acquireDumpLine(currentLineBuffer,previousLineBuffer);
	}		
	else if (currentState == ST_FrameMgr_TrackingFrame)
	{
		WAIT_FOR_HREF_LOW();
		CamIntAsm_acquireTrackingLine(currentLineBuffer,colorMap);
	}
}

/***********************************************************
	Function Name: FrameMgr_processLine
	Function Description: This function is responsible for
	parsing the received image line and performing either
	connected region mapping (if in the Tracking state) or
	sending out the raw sampled data (if in the Dumping
	state).
	Inputs:  none
	Outputs: none
***********************************************************/	
void FrameMgr_processLine(void)
{
	unsigned char i;
	volatile unsigned char dataToSend;
	unsigned char *pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
#ifdef DEBUG_TRACKED_LINE    
	unsigned char *pSendData;
    unsigned char asciiBuffer[5];
    unsigned char pixelCount = 0;
#endif    
	
	if (currentState == ST_FrameMgr_DumpingFrame)
	{
		/* we want to sit in a tight loop and send the acquired data
		sitting in current and previous line buffers out the serial
		port...it is sent out the serial port immediately instead
		of going into the UIMgr tx fifo because we can't do anything
		until its sent out anyway...may as well just get it out now	*/
		
		/* currentLineBuffer is getting "g" previousLineBuffer is getting "b-r" */
		UartInt_txByte(0x0B);			/* send the header byte */
		UartInt_txByte(lineCount);		/* send the line count */
		for (i=0; i<NUM_PIXELS_IN_A_DUMP_LINE; i+=2)
		{
			/* when a dump line is sampled, the upper byte can potentially
			have garbage in it...we don't have time to mask it off as we're
			sampling, so it is done here before we send it out...we also
			combine the samples together so we really are sending up a
			sample for line N as well as line N+1 */
			dataToSend = currentLineBuffer[i];
			dataToSend &= 0x0F;
			dataToSend <<= 4;
			dataToSend |= (previousLineBuffer[i] & 0x0F);
			
			/* dataToSend should be packed now */
			UartInt_txByte(dataToSend);
			
			/* flip the colors around since we are doing all G on Y and BR on UV */
			dataToSend = previousLineBuffer[i+1];
			dataToSend &= 0x0F;
			dataToSend <<= 4;
			dataToSend |= (currentLineBuffer[i+1] & 0x0F);
			
			/* dataToSend should be packed now */
			UartInt_txByte(dataToSend);
		}
		UartInt_txByte(0x0F);  /* send line end */
		/* once all the data is sent, increment out line count by 2 since
		we really get 2 lines worth of pixels on each pass */
		/* Update...increment only by 1, but only send 72 double-lines */
		lineCount++;
		
		/* check to see if we have retrieved all of the needed lines */
		if (lineCount >= 72)  /* half 144, since we send two lines at a time */
		{
			/* we're done, so send the dump complete?...nope, just change
			states and we should be fine */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美大片日本大片免费观看| 精品三级av在线| 欧美电影一区二区三区| 26uuu国产日韩综合| 亚洲黄一区二区三区| 国产一区二区三区四区五区入口| 99精品视频在线观看| 日韩欧美高清dvd碟片| 亚洲人成网站在线| 国产aⅴ综合色| 欧美一区欧美二区| 美女视频网站黄色亚洲| 精品日韩欧美在线| 欧美最猛性xxxxx直播| 久久一日本道色综合| 亚洲成精国产精品女| eeuss鲁一区二区三区| 久久伊人中文字幕| 免费成人小视频| 欧美日韩三级在线| 亚洲综合在线五月| 91网站在线播放| 国产精品网站在线播放| 国产激情视频一区二区三区欧美 | 日韩视频免费观看高清在线视频| 亚洲色图在线视频| 成人国产视频在线观看| 精品欧美乱码久久久久久| 五月天国产精品| 欧美日韩亚洲另类| 亚洲成人av电影| 欧美日韩视频在线观看一区二区三区| 一区二区在线看| 一本大道久久a久久精二百| 欧美国产一区二区| 成人久久视频在线观看| 国产精品久99| 91官网在线观看| 亚洲一卡二卡三卡四卡无卡久久| 在线免费观看日本一区| 亚洲午夜精品17c| 欧美日本在线一区| 美女网站色91| 国产视频一区二区在线| 国产精品中文欧美| 国产精品嫩草影院com| 成人福利视频网站| 一区二区三区不卡视频| 欧美日韩免费不卡视频一区二区三区| 亚洲成人动漫在线免费观看| 91精品在线麻豆| 国产一区二区三区av电影| 久久精品人人做人人综合 | 奇米888四色在线精品| 26uuu亚洲综合色| youjizz国产精品| 一区二区不卡在线播放 | 精品欧美一区二区三区精品久久| 狠狠久久亚洲欧美| 国产精品黄色在线观看| 欧美写真视频网站| 麻豆精品在线看| 国产精品乱码一区二三区小蝌蚪| 色综合一区二区| 欧美aaaaaa午夜精品| 国产欧美一区二区三区沐欲| 91色porny蝌蚪| 日本不卡123| 国产精品视频看| 欧美男同性恋视频网站| 国产精品亚洲а∨天堂免在线| 最近中文字幕一区二区三区| 欧美日韩国产成人在线91| 国产乱子轮精品视频| 亚洲欧洲一区二区在线播放| 在线综合+亚洲+欧美中文字幕| 高清av一区二区| 日韩精品午夜视频| 1区2区3区精品视频| 日韩丝袜美女视频| 色素色在线综合| 国产精品99久久久久久久女警| 一区二区三区国产| 亚洲国产精品成人久久综合一区 | 日韩欧美一区二区在线视频| 99精品黄色片免费大全| 风间由美中文字幕在线看视频国产欧美| 国产精品欧美久久久久无广告| 精品视频1区2区3区| 成人91在线观看| 国内成人精品2018免费看| 亚洲一区在线观看视频| 国产精品欧美一区喷水| 久久在线观看免费| 日韩一级二级三级精品视频| 日本久久电影网| 99精品热视频| 国产不卡视频一区二区三区| 麻豆精品一区二区综合av| 亚洲国产精品久久久久婷婷884| 欧美国产精品一区| 欧美www视频| 欧美一区二区福利在线| 欧美日韩精品一区视频| 色综合久久综合网97色综合| 北条麻妃一区二区三区| 国产福利视频一区二区三区| 麻豆精品一区二区综合av| 日韩电影一区二区三区四区| 一区二区三区四区乱视频| 国产精品久久久久影院| 国产亚洲一二三区| 国产人久久人人人人爽| 久久网这里都是精品| 久久综合久久99| 久久无码av三级| 国产日韩欧美综合一区| 久久精品网站免费观看| 国产人久久人人人人爽| 亚洲国产精品国自产拍av| 国产精品网友自拍| 国产精品乱人伦| 最近中文字幕一区二区三区| 亚洲欧美国产77777| 亚洲最快最全在线视频| 午夜日韩在线电影| 蜜臀av在线播放一区二区三区| 蜜臀av性久久久久蜜臀aⅴ四虎| 青青草精品视频| 国内不卡的二区三区中文字幕| 国产精品伊人色| 99在线精品一区二区三区| 91丨porny丨首页| 欧美日韩精品专区| 日韩欧美成人午夜| 欧美激情自拍偷拍| 一区二区三区中文在线观看| 亚洲.国产.中文慕字在线| 日韩电影免费在线看| 国产精品系列在线播放| 97超碰欧美中文字幕| 欧美日韩在线直播| 精品日韩在线一区| 日韩美女精品在线| 日韩中文字幕亚洲一区二区va在线 | 国产日韩综合av| 亚洲日穴在线视频| 日本视频免费一区| 成人精品高清在线| 欧美撒尿777hd撒尿| 精品国产免费视频| 亚洲伦在线观看| 男人操女人的视频在线观看欧美 | 亚洲电影一级黄| 狠狠色丁香九九婷婷综合五月| 成人免费看视频| 欧美精品第一页| 欧美国产1区2区| 午夜久久电影网| 成人少妇影院yyyy| 7777女厕盗摄久久久| 中文字幕av不卡| 日韩高清不卡在线| 91在线精品一区二区三区| 日韩欧美资源站| 亚洲精品中文在线观看| 麻豆高清免费国产一区| 91久久精品一区二区三| 久久一区二区三区四区| 亚洲午夜激情网站| av亚洲精华国产精华精华| 欧美一区二区三区免费大片| 亚洲少妇30p| 国产成人在线影院| 欧美一级一区二区| 一区二区理论电影在线观看| 精品午夜久久福利影院| 欧美日韩国产高清一区| 中文字幕一区二区视频| 国产在线日韩欧美| 欧美一级一级性生活免费录像| 亚洲综合激情另类小说区| 福利91精品一区二区三区| 26uuu精品一区二区| 日韩有码一区二区三区| 欧美性淫爽ww久久久久无| 国产精品久久久久天堂| 国产精品一区二区免费不卡| 日韩欧美国产1| 奇米影视一区二区三区| 欧美日韩卡一卡二| 懂色av一区二区夜夜嗨| 日韩精品中文字幕在线一区| 三级久久三级久久| 欧美日韩国产系列| 亚洲成人一区二区| 欧洲中文字幕精品| 亚洲一级二级三级在线免费观看| 99久久夜色精品国产网站| 国产精品伦一区二区三级视频|