智能车制作
标题:
模拟摄像头采集的图像怎么在二维数组中存放??帮忙看看代码……
[打印本页]
作者:
librae8226
时间:
2009-11-22 12:00
标题:
模拟摄像头采集的图像怎么在二维数组中存放??帮忙看看代码……
大体思路是每采完一场就关掉中断,通过串口把二值化后的图像发到PC上,出现的问题是发过来的东西全是0(阈值没有问题) - -!
#define BUFF_ROW_MAX 15
#define BUFF_COLUMN_MAX 50
volatile unsigned char buff[BUFF_ROW_MAX][BUFF_COLUMN_MAX]; //存采集的数据
volatile unsigned int SampleRow = 0; //避过场消隐用
volatile unsigned char threshold = 0x2F; //阈值
volatile unsigned char row = 0, column = 0;
volatile unsigned char SCIrow = 0, SCIcolumn = 0;
volatile Bool vStartFalg = 1; //标志新的一场开始
void interrupt 8 Port0_interrupt(void) // HS interrupt
{
unsigned int i;
TFLG1_C0F = 1; // Clear HS interrupt flag
TIE_C0I = 0; // Disable HS interrupt
if( vStartFalg ) // Avoid VS blanking
{
if ( SampleRow++ <= 5 )
{
return;
}
}
for( i = 0; i < 55; i++) // Avoid HS blanking
{
asm(nop);
}
for( column = 0; column < BUFF_COLUMN_MAX; column++ )
{
while(!ATD0STAT0_SCF);
buff[row][column] = ATD0DR0L;
}
//TIE_C0I = 0; // Disable HS interrupt,just sample one row.
vStartFalg = 0;
if( row++ <= BUFF_ROW_MAX )
{
TIE_C0I = 1;
}
}
void interrupt 9 Port1_interrupt(void)
{
TIE_C0I = 0; // Disable HS interrupt
TFLG1_C1F = 1; // Clear VS interrupt flag
/**************************************
* Send Image *
**************************************/
TIE_C1I = 0;
for( SCIrow = 0; SCIrow < BUFF_ROW_MAX; SCIrow++ )
{
for( SCIcolumn = 0; SCIcolumn < BUFF_COLUMN_MAX; SCIcolumn++ )
{
if(buff[SCIrow][SCIcolumn] > threshold)
SCI_Transmit('1');
else
SCI_Transmit('0');
delayms(150);
}
SCI_Transmit('\n');
}
SCI_Transmit('\n');
/**************************************
* End of Sending *
**************************************/
//PORTB = ~PORTB;
delayms(2);
SampleRow = 0;
vStartFalg = 1;
row = 0; // Reinitialize
TIE_C1I = 1; // Enable VS interrupt
TIE_C0I = 1; // Enable HS interrupt
}
复制代码
麻烦帮忙看看或者分享一下能实现的代码,谢谢啦~~
作者:
librae8226
时间:
2009-11-23 07:51
解决了,是两个中断开和关时候不对的问题
作者:
zhwbiao123
时间:
2010-2-26 14:31
是哦,呵呵!
作者:
zhwbiao123
时间:
2010-2-26 15:33
感觉还是多看看往届的论文
作者:
pkmaoqiao
时间:
2010-3-5 22:41
什么开和关,能具体点吗?
作者:
573377313
时间:
2010-3-6 16:14
好东西
作者:
zhizhi
时间:
2010-3-8 11:07
不是很理解
作者:
windprince
时间:
2010-3-13 10:38
回复
3#
zhwbiao123
具体中断的开关是怎么改的?
作者:
hex
时间:
2010-3-13 13:41
看看~~·
作者:
windprince
时间:
2010-3-13 17:18
回复
2#
librae8226
怎么修改的?麻烦告诉一下,谢啦
作者:
librae8226
时间:
2010-3-18 18:41
不好意思啊,好长时间没上了,我把调通的代码发上来,还没弄好的朋友们参考交流一下喽!
作者:
librae8226
时间:
2010-3-18 18:42
#include <hidef.h> /* common defines and macros */
#include <MC9S12XS128.h> /* derivative information */
#include "ATDInit.h"
#include "PortInit.h"
#include "INTInit.h"
#include "SetBusCLK.h"
#include "TimerInit.h"
#include "SCIInit.h"
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"
#define BUFF_ROW_MAX 15
#define ROW_INTERVAL 15
#define BUFF_COLUMN_MAX 35
#pragma CODE_SEG DEFAULT
//#define BUFF_ADDR 0x2500
//#define BUFF_ADDR_F $2500
/*************************************
* Variables Definition Module *
*************************************/
volatile unsigned char buff[BUFF_ROW_MAX][BUFF_COLUMN_MAX];
volatile unsigned int SampleRow = 0;
volatile unsigned char threshold = 0x2F;
volatile unsigned char row = 0, column = 0;
volatile unsigned char SCIrow = 0, SCIcolumn = 0;
volatile unsigned int rowcounter = 0;
volatile Bool vStartFalg = 1;
/*************************************
* Functions Definition Module *
*************************************/
#pragma CODE_SEG DEFAULT
//Normal Functions
void delayms(int ms) // 40MHz--1ms
{
unsigned int ii, jj;
for( ii = 0; ii < ms; ii++ )
for( jj = 0; jj < 255; jj++ );
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
//Interrupt Functions
void interrupt 8 Port0_interrupt(void) // HS interrupt
{
unsigned int i;
TFLG1_C0F = 1; // Clear HS interrupt flag
rowcounter++;
if( vStartFalg ) // Avoid VS blanking
{
if ( SampleRow++ <= 10 )
{
return;
}
}
vStartFalg = 0;
if( rowcounter % ROW_INTERVAL == 0)
{
for( i = 0; i < 100; i++) // Avoid HS blanking(35~75)
{
asm(nop);
}
TIE_C0I = 0; // Disable HS interrupt
for( column = 0; column < BUFF_COLUMN_MAX; column++ )
{
while(!ATD0STAT0_SCF);
buff[row][column] = ATD0DR0L;
}
row++;
TIE_C0I = 1;
//TIE_C0I = 0; // Disable HS interrupt,just sample one row.
if( row > BUFF_ROW_MAX )
{
TIE_C0I = 0;
TIE_C1I = 1;
}
}
}
void interrupt 9 Port1_interrupt(void) //VS interrupt
{
TIE_C0I = 0; // Disable HS interrupt
TIE_C1I = 0;
TFLG1_C1F = 1; // Clear VS interrupt flag
/**************************************
* Send Image *
**************************************/
for( SCIrow = 0; SCIrow < BUFF_ROW_MAX; SCIrow++ )
{
for( SCIcolumn = 0; SCIcolumn < BUFF_COLUMN_MAX; SCIcolumn++ )
{
if(buff[SCIrow][SCIcolumn] > threshold)
SCI_Transmit('1');
else
SCI_Transmit('0');
delayms(50);
}
SCI_Transmit('\n');
}
SCI_Transmit('\n');
PORTB_PB7 = !PORTB_PB7;
/**************************************
* End of Sending *
**************************************/
delayms(2);
SampleRow = 0;
vStartFalg = 1;
row = 0; // Reinitialize
rowcounter = 0;
//TIE_C1I = 1; // Enable VS interrupt
TIE_C0I = 1; // Enable HS interrupt
}
/*************************************
* MAIN *
*************************************/
void main(void)
{
/* put your own code here */
DisableInterrupts;
/**************************************
* Functions Initialization Module *
**************************************/
SetBusCLK(); // 80MHz
Port_Init();
ATD_Init();
Timer_Init_AV();
SCI_Init();
/**************************************
* Variables Initialization Module *
**************************************/
EnableInterrupts;
for(;;)
{
_FEED_COP(); // Feed Watchdog;
}
/* wait forever */
/* please make sure that you never leave this function */
}
复制代码
作者:
windprince
时间:
2010-3-24 18:27
回复
11#
librae8226
谢谢!
作者:
shuxinxiaozi
时间:
2010-3-25 15:13
恩,学习下!
作者:
jiutian0396
时间:
2010-4-6 20:32
顶一下
作者:
jiutian0396
时间:
2010-4-6 20:32
顶一下
作者:
botewin
时间:
2010-4-17 20:25
学习一下
作者:
kangluoyi
时间:
2010-4-24 16:38
????
作者:
jwauto
时间:
2010-6-20 19:05
kankan
作者:
yanshengbin
时间:
2010-6-22 19:31
kankan
作者:
zhangzufeng
时间:
2010-11-9 21:43
好东西
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2