본문 바로가기
Digital Logic/Zybo z7 프로젝트

[Zybo z7-20 보드 실습] Pcam 5C 영상 출력 (MIPI - HDMI)

by 고뭉나무 2021. 5. 19.

 

프로젝트 컨셉

이번에는 Zybo z7-20 보드로 해보고 싶었던 카메라 Pcam 5C 실습을 해보겠습니다 

PCam 5C는 MIPI 통신을 사용하며 보드에 장착되어 있는 HDMI TX 포트를 이용하여 모니터에 촬영되는 영상을 출력할 것입니다.

 

PCam 카메라 모듈을 이용하여 HDMI로 영상을 출력한다

 

 

Pcam Tutorial 정리

Pcam도 Digilent에서 제작하는 모듈이라 아래 처럼 친절하게 Tutorial을 작성해주었다.

https://reference.digilentinc.com/learn/programmable-logic/tutorials/zybo-z7-pcam-5c-demo/start?_ga=2.155411774.408121669.1620950911-477770147.1617751612

 

Zybo Z7 Pcam 5C Demo - Digilent Reference

 

reference.digilentinc.com

 

간단하게 정리하면,

  • 이미지 input: Pcam 5C - MIPI interface
  • 이미지 output: Monitor - HDMI TX
  • 카메라 센서: OV5640 5MP
  • Sensor output format: RAW
  • Image processing features: AWB, Defective Pixel Canceling, Auto Exposure Control, Gamma correction, etc..
  • Required HW: Zybo z7-20 board, Micro-USB cable, HDMI Cable, Pcam 5C, HDMI monitor

 

HW IP 소스 출처

관련 HW IP 소스는 Digilent사에서 제공한다.
주의할 점은 아래 버전과 Vivado 버전을 꼭 동일하게 맞춰야 한다. 안그럼, 합성할 때 타이밍 에러가 발생한다.
https://github.com/Digilent/Zybo-Z7-20-pcam-5c?_ga=2.244553101.907599117.1619131526-477770147.1617751612
https://github.com/Digilent/Zybo-Z7-20-pcam-5c/releases

 

실습

위에서 다운로드한 파일을 open 한 후에 Synthesis와 Implementation을 하지 않고

Generate Bitstream만 진행하여 Hardware platform 파일을 생성한다.

(필자는 처음에 Synthesis와 Implementation을 하니 Timing 에러가 발생하였다. 거기다 intra-clock에 violation까지 발생하여 에러 디버깅을 꼭 해야하는 상황이 왔었는데. 결국 원본 파일에 Generate bitstream만 돌리니 정상적으로 잘 작동하더라..)


아래와 같이 Timing error 가 있긴 하지만 이건 무시해도 정상적으로 동작시킬 수 있다. (그러니 걱정 노노)

그리고 늘 그랬듯 완성된 Hardware platform을 Export하여 파일을 만든다.

형식은 .hdf

그리고 이제 Vivado SDK 프로그램으로 넘어가 Create Application을 하고 'pcam_vdma_hdmi' 프로젝트를 생성한다.

이 때, 위에서 만든 system_wrapper.hdf를 꼭 넣어주어야 한다. (이것이 핵심!)

그리고 이제 Application단에서 실행할 main.cc 파일을 추가해준다. 이 파일 또한 위의 오픈 소스로 공유되어 있으니 이를 활용하면 된다.

이렇게 차곡차곡 완성한 후, project를 build하고 Program FPGA을 한다.

그리고 마지막으로 Run As - Launch on Hardware를 하면 

Serial 통신을 연결한 프로그램에 뙇!

이렇게 Pcam 5C를 제어할 수 있는 명령들이 나오면서 HDMI Monitor에 Pcam 5C로 촬영한 실시간 영상이 출력되는 것을 알 수 있다.

 

영상 제어 종류

Digilent에서 제공한 오픈소스에는 총 6개의 제어 메뉴를 제공하였다. (총 7개지만 하나는 나가리..)

 

1 - Change Resolution
This option can be used to change the resolution of the video coming from the sensor. Currently 1080p@15Hz is not supported and will cause problems if used.
2 - Change Liquid Lens Focus
This option is not compatible with this version of the Pcam 5C and should be ignored
3 - Change Image Format
This option was included for debugging purposes and should always be set to RAW mode (option 2)
4 - Write a Register inside the Image Sensor
This option allows you to write a value to any register inside the Image sensor over the OmniVision SCCB interface. You will need to refer to the OV5640 datasheet for information on the register map. This option is very useful for exploring the features of the image sensor.
5 - Read a Register inside the Image Sensor
This option allows you to read the value of any register inside the Image sensor over the OmniVision SCCB interface.
6 - Change Gamma Correction Factor Value
This option allows you to change the amount of gamma correction that is done by the custom AXI stream IP inside the FPGA.
7 - Change AWB Settings
This option allows you to adjust how the image sensor is doing auto white balancing. There are 3 modes: Advanced, simple, and disabled. The advanced mode sometimes causes dramatic shifts between “red-ish” and “blue-ish” tints.

 

이 중에서 1, 6, 7번은 아래 영상과 함께 실습 결과를 공개하겠다. 

그리고 OV5640의 Register를 통해 더 많은 카메라 기능을 제어할 수 있는 4번의 경우 다음 포스팅을 통해 더 자세히 다뤄보도록 하겠다.

 

 

실습 결과

실습 1 - Change Resolution

https://www.youtube.com/watch?v=Kz8c_jcmtf0 

 

실습 6 - Change Gamma Correction Factor Value

https://www.youtube.com/watch?v=LwzeJCqNEo8 

 

실습 7 - Change AWB Settings


https://www.youtube.com/watch?v=43z9AaaUwRI 

 

 

 

위 글이 도움이 되셨나면, 아래 하트를 눌러주세요↓

감사합니다 \( ˆoˆ )/​

반응형

댓글