'중도연재종료'에 해당되는 글 37건

  1. 2013.06.14 Get Character
  2. 2013.06.14 당분간 정지
  3. 2013.06.09 cvMat
  4. 2013.06.09 이미지 열기
  5. 2013.06.08 CvMat 행렬 자료구조
  6. 2013.06.08 기초
  7. 2013.06.08 시작...
  8. 2013.06.08 UART_ Hello_Wolrd 찍기_2
  9. 2013.06.08 UART_ Hello World 찍기_1
  10. 2013.05.25 n비트 비교기 설계

USART의 RS 스텟을 본다.


#define USART_FLAG_RXNE    ((uint16_t)0x0020)

:Read data register not empty

multi-buffer 통신 등의 상황에서 사용


1은 데이터가 수신되어 읽을 수 있는 상태가 되었다는 것을 의미

0은 데이터가 아직 수신되지 않았다는 의미


RDR shift register[각주:1]가 데이터를 수신하고 이것을 USART_DR register로 옮기게 된다. 모두 옮겨졌을 경우 이 비트가 1이 된다.


rc_w0:read & c_w0

c_w0 : 0을 write함으로써 이 비트는 0으로 clear 된다는 것을 의미

c_w1 : 1을 write함으로써 비트가 0으로 clear 된다.


uint16_t USART_ReceiveData(USART_TypeDef* USARTx)

{

/* Receive Data */

return (uint16_t)(USARTx->DR & (uint16_t)0x01FF);

}

USART_DR레지스터에서 값을 읽어온다.

USART_DR레지스터의 아홉비트만이 의미가 있다.


  1. 어디있냐? [본문으로]

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

RCC_GetClockFreq  (0) 2013.06.23
Clock Control  (0) 2013.06.23
당분간 정지  (0) 2013.06.14
UART_ Hello_Wolrd 찍기_2  (0) 2013.06.08
UART_ Hello World 찍기_1  (0) 2013.06.08
Posted by 십자성군

그때그때 정리하니까 시간이 너무 걸린다.

빨리빨리 해서 한번 다 하고 적어나가자

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

Clock Control  (0) 2013.06.23
Get Character  (0) 2013.06.14
UART_ Hello_Wolrd 찍기_2  (0) 2013.06.08
UART_ Hello World 찍기_1  (0) 2013.06.08
GPIO_Init  (0) 2013.05.25
Posted by 십자성군
중도연재종료/OPENCV2013. 6. 9. 15:45

CvMat* cvCreateMatHeader(int rows, int cols,int type);

행, 열과 행렬요소의 자료형을 인수로 주면 행렬의 헤더를 생성하여 포인터를 반환


void cvCreateDate(CvArr* arr);

행렬 또는 영상 포인터인 arr의 헤더에 맞게 행렬 또는 영상 메모리 할당.


void cvReleaseData(CvArr* arr);

포인터인 arr에 할당된 메모리만을 해제한다.


CvMat* cvInitMatHeader(CvMat* mat, int rows, int cols, int type, void* date=NULL, int step=CV_AUTOSTEP);

인수 rows, cols, type, data, step을 이용하여 CvMat포인터 인수인 mat을 초기화 한다.


CvMat cvMat(int rows, int cols, int type, void* date=NULL);

CvMat 자료형의 인스턴스를 생성하여 반환.


cvSetReal*D

1채널 행렬.영상에서만 사용 가능

idx에 의해 지정된 요소 값을 double형 인수인 value값으로 변경한다.


cvSet*D

1,2,3채널의 행렬 및 영상에서 사용

idx에 의해 지정된 요소 값을 CvScalar형 인수인 value값으로 변경


cvGetReal*D

1채널에서만 사용 가능

idx등에 의해 지정된 요소 값을 double형으로 반환


cvGet*D

1,2,3채널에서 사용 가능

CvScalar형으로 반환


cvmGet, cvmSet

1채널인 실수 행렬에서만 사용 가능

cvmGet : row, col위치의 요소 값을 double형으로 반환

cvmSet : row,col위치의 요소 값을 double형 인수인 value값으로 변경


cvPtr*D

주어진 행렬 또는 영상에서 첨자로 지정된 요소의 포인터를 반환


cvSet, cvSetZero

arr의 모든 요소 또는 화소 값을 value, 0로 변경


CV_MAT_ELEM




'중도연재종료 > OPENCV' 카테고리의 다른 글

이미지 열기  (0) 2013.06.09
CvMat 행렬 자료구조  (0) 2013.06.08
기초  (0) 2013.06.08
시작...  (0) 2013.06.08
Posted by 십자성군
중도연재종료/OPENCV2013. 6. 9. 01:35

IplImage* ImageOpen()

{

    IplImage* image = 0;

    image = cvLoadImage("t9t9.jpg", 1);

 

    cvNamedWindow( "T9-viewer", 1);

    cvShowImage( "T9-viewer", image );

    cvWaitKey(0);

 

    cvDestroyWindow( "T9-viewer" );

return image;

}


1.IplImage

typedef struct _IplImage

{

int nSize;

int ID;

int nChannels;            //채널의 개수. 1~4

int alphaChannel;       

int depth;                    //화소의 비트표현 depth정보를 갖음(8비트 unsigned~64비트 배정도 실수)

char colorModel[4];

char channelSeq[4];

int dataOrder;             //채널 자료의 저장 순서{0:인터리브 컬러채널, 1:분리 컬러채널}

int origin;                    //영상의 원점{0:왼쪽 상단, 1:왼쪽 하단(비트맵 처럼). 기본 0}

int align;

int width;                    //가로방향 화소수

int height;

struct _IplROI *roi;        //Region Of Interest(ROI) 영상에서 관심영역.coi, xOffset,yOffset,width,height

struct _IplImage *maskROI;

void *imageld;

struct _IplTileInfo *tileInfo;

int imageSize;

char *imageData;

int widthStep;            //한 행의 바이트 개수

int BorderMode[4];

int BorderConst[4];

char *imageDataOrigin;

}


IplImage* cvLoadImage(const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR);

:iscolor-> CV_LOAD_IMAGE_COLOR : 3채널 컬러 영상, CV_LOAD_IMAGE_GRAYSCALE : 1채널 그레이 스케일, CV_LOAD_IMAGE_UNCHANGED : 원본 영상 그대로


int cvSaveImage(const char* filename, const CvArr* image);

영상을 파일에 저장. 포맷은 파일 확장자에 의해 정해지며, 8비트 단일 채널과, 3채널 컬러영상으로 저장 가능


int cvWaitKey(int delay=0);

delay/1000초 만큼 지연 대기. delay=0이면 키를 누를 때 까지 무한히 대기


int cvNamedWindow(const char* name, int flags);

윈도우 생성. name은 식별 ID로 사용.

flag = CV_WINDOW_AUTOSIZE : 영상의 크기에 맞게 윈도우 크기 자동 조절


void cvShowImage(const char* name, const CvArr* image);

name 이름을 갖는 윈도우에 영상 image를 보여준다. 영상 크기에 맞게 윈도우의 크기가 스케일 된다.


void cvDestroyWindow(const char* name);

윈도우 파괴. cvDestroyAllWindows(void)로 모든 윈도우 파괴 가능

'중도연재종료 > OPENCV' 카테고리의 다른 글

cvMat  (0) 2013.06.09
CvMat 행렬 자료구조  (0) 2013.06.08
기초  (0) 2013.06.08
시작...  (0) 2013.06.08
Posted by 십자성군
중도연재종료/OPENCV2013. 6. 8. 23:04

2차원 행렬을 위한 자료구조이다.




typedef struct CvMat

{

    int type;    //행렬 요소 자료형

    int step;


    /* for internal use only */

    int* refcount;

    int hdr_refcount;


    union

    {

        uchar* ptr;

        short* s;

        int* i;

        float* fl;

        double* db;

    } data;


#ifdef __cplusplus

    union

    {

        int rows;

        int height;

    };


    union

    {

        int cols;

        int width;

    };

#else

    int rows;

    int cols;

#endif


}

CvMat;


CvMat 행렬 생성 및 파괴


행렬의 헤더를 생성한다 : CvMat 구조체의 멤버변수를 초기화 한다.


1)CvMat* cvCreateMat(int rows, int cols, int type);

CV_8UC1과 같은 행렬요소의 자료형(type)을 이수로 주면, 행렬의 헤더를 생성하고, 행렬 요소를 저장하기 위한 메모리를 할당하여 포인터를 반환한다.


2)void cvReleaseMat(CvMat** mat);

행렬을 생성할 때 할당된 메모리를 해제한다. 2중 포인터에 주의


3)void cvSetReal2D(CvArr* arr, int idx(), int idx1, double value);

2차원 행렬(CvMat) 또는 영상(IplImage)포인터인 arr의 idx0 행, idx1 열의 요소 값에 value의 값을 저장한다.

1채널인 행렬 또는 영상에서만 사용할 수 있다.

:행렬, 영상 포인터를 받아 그 배열의 idx0열 idx1행에 value 값 저장.


4)double cvGetReal2D(const CvArr* arr, int idx0, int idx1);

2차원 행렬 또는 영상 포인트인 arr의 행 열의 "요소값"을 double형으로 반환한다.

1채널인 행렬 또는 영상에서만 사용 가능하다


5)CvArr 자료형(typedef void CvArr;)

서로 다른 자료형 사이에 형 변환을 위해 사용된다.

CvMat* 또는 IplImage* 형태의 인수를 전달 받는데 사용한다.


cvSetReal2D, cvGetReal2D 은 행렬 및 영상 모두에 사용할 수 있음에 주의 


1채널은 Gray, 3채널은 3요소 영상(RGB,HSI,vCbCr)...을 말하겠지...


ex)

'중도연재종료 > OPENCV' 카테고리의 다른 글

cvMat  (0) 2013.06.09
이미지 열기  (0) 2013.06.09
기초  (0) 2013.06.08
시작...  (0) 2013.06.08
Posted by 십자성군
중도연재종료/OPENCV2013. 6. 8. 22:32


자료형 

멤버변수 

인라인 함수 이름 

설명 

CvPoint 

x,y 

cvPoint 

int형 2D 화소 위치 

CvPoint2D32f 

x,y, 

cvPoint2D32f 

float형 2D 화소 위치 

CvPoint2D65f 

x,y 

cvPoint2D64f 

double형 2D 화소 위치 

CvScalar 

valp4[ 

cvScalar,

cvRealScalar,

cvScalarAll 

화소의 밝기 값 또는 컬러 값 표현

그레이 스케일 영상 : val[0]

컬러 영상: val[0]=B

               val[1]=G             

               val[2]=R

               val[3]=alpha


인라인 함수 설명

CV_INLINE CvPoint cvPoint(int x, int y)

{

CvPoint p;

p.x=x;

p.y=y;

return p;

}


CV_INLINE CvPoint2D32f cvPoint2D32f(double x, double y)

{

CvPoint2D32f p;

p.x = (float)x;

p.y = (float)y;

return p;

}


CV_INLINE CvPoint2D64f cvPoint2D32f(double x, double y)

{

CvPoint2D64f p;

p.x = (float)x;

p.y = (float)y;

return p;

}


CV_INLINE CvScalar cvScalar(double val0, double val1 CV_DEFAULT(0), double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0))

{

CvScalar scalar;

scalar.val[0]=val0; scalar.val[1]=val1;

scalar.val[2]=val2; scalar.val[3]=val3;

return scalar;

}


CV_INLINE CvScalar cvRealScalar(double val0)

{

CvScalar scalar;

scalar.val[0]=val0;

scalar.val[1]=scalar.val[2]=scalar.val[3]=0;

return scalar;

}


CV_INLINE Cvscalar cvScalarAll(double val0123)

{

CvScalar scalar;

scalar.val[0]=val0123;

scalar.val[1]=val0123;

scalar.val[2]=val0123;

scalar.val[3]=val0123;

}


ex1)


#include <iostream>

#include <opencv\cv.h>

#include <opencv\highgui.h>



int test01()

{

CvPoint pt0 = cvPoint(10,20);

CvPoint2D32f pt1 = cvPoint2D32f(30.0,40.0);

CvPoint2D64f pt2 = cvPoint2D64f(50.0,60.0);


printf("pt0 : %d, %d\n",pt0.x,pt0.y);

printf("pt1 : %f,%f\n",pt1.x,pt1.y);

printf("pt2 : %f, %f\n", pt2.x,pt2.y);

return 0;

}


int test02()

{

CvScalar color1 = cvScalar(255,255,255);

CvScalar color2 = cvScalar(255);

CvScalar color3 = cvRealScalar(255);

CvScalar color4 = cvScalarAll(255);

printf("color1.val: %f, %f, %f, %f\n", color1.val[0], color1.val[1], color1.val[2], color1.val[3]);

printf("color2.val: %f, %f, %f, %f\n", color2.val[0], color2.val[1], color2.val[2], color2.val[3]);

printf("color3.val: %f, %f, %f, %f\n", color3.val[0], color3.val[1], color3.val[2], color3.val[3]);

printf("color4.val: %f, %f, %f, %f\n", color4.val[0], color4.val[1], color4.val[2], color4.val[3]);


return0;

}

------------------------------------------------------------------------------------------------

typedef struct

{

int width;

int height;

}CvSize;


CV_INLINE CvSize cvSize(int width, int height)

{

CvSize s;

s.width = width;

s.height = height;

return s;

}


typedef struct CvRect

{

int x;

int y;

int width;

int height;

}CvRect;


CV_INLINE CvRect cvRect(int x, int y, int width, int height)

{

CvRect r;

r.x = x;

r.y = y

r.width = width;

r.height = height;

return r;

}


ex3)

int test03()

{

CvSize size = cvSize(720,480);

CvRect rect = cvRect(100,100,400,200);

CvPoint pt1,pt2;


printf("size : %d, %d\n", size.width, size.height);


pt1.x = rect.x;

pt1.y = rect.y;


pt2.x = rect.x + rect.width;

pt2.y = rect.y + rect.height;


printf(":Left Top Point(p1) : %d, %d\n", pt1.x, pt1.y);

printf("Right Bottom Point(p2) : %d, %d\n", pt2.x, pt2.y);

return 0;

}


...cvScalar는 가변인수함수?


함수, 변수 등의 형태를 잘 알고 사용하자!

'중도연재종료 > OPENCV' 카테고리의 다른 글

cvMat  (0) 2013.06.09
이미지 열기  (0) 2013.06.09
CvMat 행렬 자료구조  (0) 2013.06.08
시작...  (0) 2013.06.08
Posted by 십자성군
중도연재종료/OPENCV2013. 6. 8. 22:27

영상처리 기초공부는 했고...


심심할때마다 하기로 함.

'중도연재종료 > OPENCV' 카테고리의 다른 글

cvMat  (0) 2013.06.09
이미지 열기  (0) 2013.06.09
CvMat 행렬 자료구조  (0) 2013.06.08
기초  (0) 2013.06.08
Posted by 십자성군

자세한 이론 내용은 책 참조... 정리하는데 시간이 너무 지나감


void GPIO_Configuration(void)

{

  GPIO_InitTypeDef GPIO_InitStructure; 

  

  GPIO_InitStructure.GPIO_Pin = GPIO_USART_Tx_Pin;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

  GPIO_Init(GPIO_USART,&GPIO_InitStructure);

  

  GPIO_InitStructure.GPIO_Pin = GPIO_USART_Rx_Pin;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

  GPIO_Init(GPIO_USART,&GPIO_InitStructure);

}




void USART1_Init(void)

{

  USART_InitTypeDef USART_InitStructure; 

  

  /*USARTx configured as follow:

  -BaudRate : 115200 baud

  -Word Length = 8bits

  -One Stop Bit

  -No parity

  -Hardware flow control disabled (RTS and CTS signals)

  -Receive and transmit enabled

  */

  

  USART_InitStructure.USART_BaudRate = 115200;

  USART_InitStructure.USART_WordLength = USART_WordLength_8b;

  USART_InitStructure.USART_StopBits = USART_StopBits_1;

  USART_InitStructure.USART_Parity = USART_Parity_No;

  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

  USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx;

  

  //Configure the USARTx

  

  USART_Init(USART1, &USART_InitStructure);

  

  //Enable the USART1

  USART1->CR1 |= CR1_UE_Set;

}


typedef struct

{

  __IO uint16_t SR;

  uint16_t  RESERVED0;

  __IO uint16_t DR;

  uint16_t  RESERVED1;

  __IO uint16_t BRR;

  uint16_t  RESERVED2;

  __IO uint16_t CR1;

  uint16_t  RESERVED3;

  __IO uint16_t CR2;

  uint16_t  RESERVED4;

  __IO uint16_t CR3;

  uint16_t  RESERVED5;

  __IO uint16_t GTPR;

  uint16_t  RESERVED6;

} USART_TypeDef;


UART : CPU에서 나오는 신호레벨(TTL)

RS-232 : SP


P240. Reference Table180 참조

BaudRate

:Tx/Rx baud=fck/(16*USARTDIV)

ex)Baudrate 115200으로 잡을 경우

DIV_Mantissa=39=0b100111=0x27

DIV_Fraction=16*0.625=10=0xA

USARTDIV=0x27A


WordLength

#define USART_WordLength_8b                  ((uint16_t)0x0000)

#define USART_WordLength_9b                  ((uint16_t)0x1000)


StopBits

#define USART_StopBits_1                     ((uint16_t)0x0000)

#define USART_StopBits_0_5                   ((uint16_t)0x1000)

#define USART_StopBits_2                     ((uint16_t)0x2000)

#define USART_StopBits_1_5                   ((uint16_t)0x3000)


Parity

#define USART_Parity_No                      ((uint16_t)0x0000)

#define USART_Parity_Even                    ((uint16_t)0x0400)

#define USART_Parity_Odd                     ((uint16_t)0x0600) 


HadwafeFlowControl

#define USART_HardwareFlowControl_None       ((uint16_t)0x0000)

#define USART_HardwareFlowControl_RTS        ((uint16_t)0x0100)

#define USART_HardwareFlowControl_CTS        ((uint16_t)0x0200)

#define USART_HardwareFlowControl_RTS_CTS    ((uint16_t)0x0300)


USART_Mode

#define USART_Mode_Rx                        ((uint16_t)0x0004)

#define USART_Mode_Tx                        ((uint16_t)0x0008)


#define CR1_UE



void SerialPutChar(uint8_t c){

  USART_SendData(USART1,c);

  while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);

}


USART_FLAG_TXE : 송신을 할 수 있는 상태인지 검사


새로운 명령

apbclock = HSI_Value

CR2_STOP_CLEAR_Mask

USART_StopBits

CR1_CLEAR_Mask

USART_WordLength

USART_Parity

USART_Mode

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

Get Character  (0) 2013.06.14
당분간 정지  (0) 2013.06.14
UART_ Hello World 찍기_1  (0) 2013.06.08
GPIO_Init  (0) 2013.05.25
Key가 눌린것 알아채기  (0) 2013.05.24
Posted by 십자성군

P224~



UART : CPU에서 나오는 신호레벨(TTL 레벨)

RS-232 : UART칩을 거쳐 나온 신호


#define USART1_BASE    (APB2PERIPH_BASE + 0x3800)    관련 RSMap은 맨 위의 표와 같음

#define USART1            ((USART_TypeDef*)USART1_BASE)



<Source_Code>


#include <stm32f10x.h>


#define GPIO_USART  GPIOA

#define GPIO_USART_Rx_Pin GPIO_Pin_10

#define GPIO_USART_Tx_Pin GPIO_Pin_9


//GPIOA의 10번과 9번 핀을 각각 수.송신부로 사용하고 있다.


void GPIO_Configuration(void)

{

  GPIO_InitTypeDef GPIO_InitStructure; 

  

  GPIO_InitStructure.GPIO_Pin = GPIO_USART_Tx_Pin;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

  GPIO_Init(GPIO_USART,&GPIO_InitStructure);

  

  GPIO_InitStructure.GPIO_Pin = GPIO_USART_Rx_Pin;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

  GPIO_Init(GPIO_USART,&GPIO_InitStructure);

}


void USART1_Init(void)

{

  USART_InitTypeDef USART_InitStructure; 

  

  /*USARTx configured as follow:

  -BaudRate : 115200 baud

  -Word Length = 8bits

  -One Stop Bit

  -No parity

  -Hardware flow control disabled (RTS and CTS signals)

  -Receive and transmit enabled

  */

  

  USART_InitStructure.USART_BaudRate = 115200;

  USART_InitStructure.USART_WordLength = USART_WordLength_8b;

  USART_InitStructure.USART_StopBits = USART_StopBits_1;

  USART_InitStructure.USART_Parity = USART_Parity_No;

  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

  USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx;

  

  //Configure the USARTx

  

  USART_Init(USART1, &USART_InitStructure);

  

  //Enable the USART1

  USART1->CR1 |= CR1_UE_Set;

}


void Serial_PutString(uint8_t *s){

  while(*s != '\0'){

    SerialPutChar(*s);

    s++;

  }

}


void RCC_Set(void){

  RCC->APB2ENR |= RCC_APB2Periph_USART1;

}


int main(void)

{

  RCC_Set();


  GPIO_Configuration();

  

  USART1_Init();


  while(1){

 Serial_PutString("\r\nHello World! Hello Cortex-M3!\r\n") ; 

  }

}




'중도연재종료 > CORTEX M3' 카테고리의 다른 글

당분간 정지  (0) 2013.06.14
UART_ Hello_Wolrd 찍기_2  (0) 2013.06.08
GPIO_Init  (0) 2013.05.25
Key가 눌린것 알아채기  (0) 2013.05.24
고급스러운 코딩1.  (0) 2013.05.24
Posted by 십자성군
중도연재종료/VHDL2013. 5. 25. 13:56



A와 B입력을 비교하여 같으면 EQ에 1, B가 더 크면 LT에 1, A가 더 크면 GT에 1이 출력된다.






작은 비교기간의 조합으로 큰 비교기를 설계할 수 있다. 예를들어 1비트 비교기와 2비트 비교기를 조합하여 3비트 비교기를 설계할 수 있겠다.





4비트 비교기와 그 로직이다.


과제:

3,2,1비트 비교기 설계

Posted by 십자성군