SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Camera.cpp
- Committer:
- hazheng
- Date:
- 2017-02-01
- Revision:
- 3:c8867972ffc7
File content as of revision 3:c8867972ffc7:
#include "Camera.h" DigitalOut testLED(LED_BLUE, 1); void Camera::OnPixelClock() { m_pics[m_currentIndex][(m_currentRow * CAM_MAX_COL) + m_currentCol++] = 0;//m_dIn[0].read(); m_pics[m_currentIndex][(m_currentRow * CAM_MAX_COL) + m_currentCol++] = 0;//m_dIn[1].read(); m_pics[m_currentIndex][(m_currentRow * CAM_MAX_COL) + m_currentCol++] = 0;//m_dIn[2].read(); m_pics[m_currentIndex][(m_currentRow * CAM_MAX_COL) + m_currentCol++] = 0;//m_dIn[3].read(); m_pics[m_currentIndex][(m_currentRow * CAM_MAX_COL) + m_currentCol++] = 0;//m_dIn[4].read(); m_pics[m_currentIndex][(m_currentRow * CAM_MAX_COL) + m_currentCol++] = 0;//m_dIn[5].read(); m_pics[m_currentIndex][(m_currentRow * CAM_MAX_COL) + m_currentCol++] = 0;//m_dIn[6].read(); m_pics[m_currentIndex][(m_currentRow * CAM_MAX_COL) + m_currentCol++] = 0;//m_dIn[7].read(); } void Camera::OnHorizontalClock() { m_currentRow++; m_currentCol = 0; } void Camera::OnFrameClock() { m_currentIndex = m_currentIndex == 0 ? 1 : 0; m_currentRow = 0; m_currentCol = 0; m_hasPic = true; testLED = testLED.read() == 1 ? 0 : 1; } Camera::Camera() : m_pClock(InterruptIn(PTD7)), m_href(InterruptIn(PTD6)), m_vsnyc(InterruptIn(PTA17)), m_currentIndex(0), m_currentRow(0), m_currentCol(0), m_hasPic(false) { m_dIn.push_back(DigitalIn(PTE5)); m_dIn.push_back(DigitalIn(PTE4)); m_dIn.push_back(DigitalIn(PTE3)); m_dIn.push_back(DigitalIn(PTE2)); m_dIn.push_back(DigitalIn(PTB11)); m_dIn.push_back(DigitalIn(PTB10)); m_dIn.push_back(DigitalIn(PTB9)); m_dIn.push_back(DigitalIn(PTB8)); //m_pClock.fall(callback(this, &Camera::OnPixelClock)); m_href.rise(callback(this, &Camera::OnHorizontalClock)); m_vsnyc.rise(callback(this, &Camera::OnFrameClock)); } Camera::~Camera() { } bool Camera::HasPicture() const { return m_hasPic; } const unsigned char * Camera::GetPicture() const { return m_pics[m_currentIndex == 0 ? 1 : 0]; }