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

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

?? framemgr.c

?? AVR與圖像傳感器OVA6620的接口程序 通過I2C總線進行通信對圖像進行采集和預處理
?? 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一区二区三区免费野_久草精品视频
久久成人久久爱| 亚洲精品在线免费播放| 亚洲一区二区免费视频| 风间由美性色一区二区三区| 91精品国产一区二区三区| 亚洲精品欧美综合四区| 99re这里都是精品| 亚洲综合色网站| 欧美性猛交xxxxxx富婆| 亚洲一区欧美一区| 欧美日韩一区三区| 亚洲一区在线电影| 欧美美女激情18p| 日韩成人免费电影| 欧美人牲a欧美精品| 无吗不卡中文字幕| 久久综合色之久久综合| 国产成人午夜精品影院观看视频 | 色又黄又爽网站www久久| 亚洲三级在线播放| 日韩一区二区三区视频| 国内精品国产成人国产三级粉色 | 国产精品久久久久久久久晋中 | 亚洲国产欧美在线人成| 日韩欧美成人激情| 国产麻豆精品95视频| 亚洲欧洲韩国日本视频| 欧美午夜精品一区二区蜜桃| 久久精品国产第一区二区三区| 国产午夜精品在线观看| 91无套直看片红桃| 久久99国产精品尤物| 一区二区三区小说| 91精品国产日韩91久久久久久| 国产高清一区日本| 日本vs亚洲vs韩国一区三区| 欧美经典一区二区三区| 91精品国产黑色紧身裤美女| 一道本成人在线| av成人免费在线观看| 美女网站色91| 亚洲a一区二区| 亚洲乱码日产精品bd| 久久久噜噜噜久久中文字幕色伊伊| 欧美日韩综合色| 欧美吞精做爰啪啪高潮| 成人18视频日本| 韩国v欧美v日本v亚洲v| 亚洲v精品v日韩v欧美v专区| 一区二区三区日本| 亚洲人吸女人奶水| 亚洲天堂2016| 一区二区三区波多野结衣在线观看| 国产精品天干天干在观线| 欧美va亚洲va香蕉在线| 欧美综合一区二区| 欧美性猛片xxxx免费看久爱| 91色九色蝌蚪| 欧美三日本三级三级在线播放| 成人美女视频在线看| www.日韩大片| www..com久久爱| 91日韩一区二区三区| 91成人免费网站| 欧美一区二区福利视频| 久久网站热最新地址| 欧美xxxxxxxx| 国产精品久久看| 亚洲成人精品影院| 蜜桃av一区二区三区电影| 韩国v欧美v日本v亚洲v| 成人av片在线观看| 色视频成人在线观看免| 欧美另类videos死尸| 91精品国产欧美一区二区成人| 欧美一区二区三区精品| 欧美—级在线免费片| 亚洲午夜在线电影| 国产成人免费av在线| 在线精品视频一区二区三四| 精品国产91乱码一区二区三区| 日韩一区二区三区在线视频| 日本一区二区三区四区在线视频| 亚洲一线二线三线视频| 国产不卡一区视频| 激情亚洲综合在线| 国产精品影视网| 欧美视频日韩视频| 亚洲国产精品成人综合色在线婷婷| 一区二区不卡在线播放| 国产传媒欧美日韩成人| 欧美久久久久免费| 亚洲色欲色欲www在线观看| 国产精品乡下勾搭老头1| 欧美一区二区三区在线观看 | 欧美日韩综合不卡| 一二三四社区欧美黄| 91亚洲永久精品| 国产精品毛片久久久久久久| 国产高清亚洲一区| **欧美大码日韩| 91视频免费观看| 国产午夜精品久久久久久免费视| 亚洲欧美在线另类| 成人黄色777网| 亚洲乱码精品一二三四区日韩在线| 国产白丝精品91爽爽久久| 正在播放一区二区| 亚洲线精品一区二区三区| 在线观看91精品国产入口| 亚洲成人免费观看| 成人av先锋影音| 久久精品日产第一区二区三区高清版| 日韩av电影一区| 日韩欧美国产一区二区三区| 国产盗摄视频一区二区三区| 欧美一区二区三区喷汁尤物| 亚洲成av人片在线观看无码| 欧美自拍偷拍一区| 日韩成人伦理电影在线观看| 欧美精品一区二区三区久久久| 国产suv精品一区二区三区| 精品国产人成亚洲区| 不卡视频一二三| 奇米777欧美一区二区| 国产欧美日韩在线视频| 欧美三级日韩在线| 亚洲成人免费av| 久久久久久9999| 欧洲一区在线电影| 青青国产91久久久久久| 国产精品女主播av| 91国产成人在线| 美女国产一区二区| 日日夜夜免费精品视频| 国产三级精品视频| 在线观看91精品国产入口| 蜜桃av一区二区| 亚洲六月丁香色婷婷综合久久 | 一区二区三区高清| 国产午夜精品一区二区 | 亚洲视频免费在线观看| 欧美三级欧美一级| 亚洲柠檬福利资源导航| 欧美sm美女调教| 91麻豆国产精品久久| av一本久道久久综合久久鬼色| 水蜜桃久久夜色精品一区的特点| 亚洲国产电影在线观看| 欧美v国产在线一区二区三区| 欧美一级高清片| www一区二区| 日韩美女在线视频| 欧美日韩国产免费一区二区 | 久久新电视剧免费观看| 日韩三级中文字幕| 欧美综合在线视频| 欧美体内she精高潮| 欧美色视频一区| 欧美日韩夫妻久久| 在线一区二区视频| 91精品福利在线| 欧美日韩精品一区二区在线播放| 9191久久久久久久久久久| 欧美三级日韩三级| 日韩午夜在线影院| 日韩女优视频免费观看| 色哟哟日韩精品| 欧美日韩国产综合一区二区| 丰满白嫩尤物一区二区| 麻豆国产精品一区二区三区| 男人的j进女人的j一区| 国产乱码精品一区二区三区av| 91麻豆自制传媒国产之光| 99re在线视频这里只有精品| 色婷婷综合久久久| 久久久亚洲精品一区二区三区| 中文久久乱码一区二区| 亚洲靠逼com| 国产一区不卡精品| 欧美在线免费观看亚洲| 欧美日韩精品一区二区三区四区| 欧美久久久一区| 2023国产精品视频| 亚洲在线观看免费| 成人午夜看片网址| 欧美一a一片一级一片| 国产日韩成人精品| 久久99精品久久久久久动态图 | 欧美电影一区二区三区| 国产精品网站导航| 播五月开心婷婷综合| 国产亚洲一区二区三区四区 | 93久久精品日日躁夜夜躁欧美| 国产69精品久久777的优势| voyeur盗摄精品| 国产精品久久久久久久岛一牛影视| 亚洲成年人网站在线观看| 在线视频一区二区免费| 久久久国际精品|