Skip to content

Commit

Permalink
fix(Examples): Updated CAM02 examples (#963)
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Carter <jhcarter.co@gmail.com>
Co-authored-by: Jake Carter <Jake.Carter@analog.com>
  • Loading branch information
3 people committed Apr 16, 2024
1 parent a96ccc6 commit 0038d43
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Examples/MAX78000/CNN/cats-dogs_demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Description
-----------

The model trained in this demo is used to classify images of cats and dogs. 25000 images dataset is used to train the model. The dataset can be downloaded using�[https://www.kaggle.com/c/dogs-vs-cats/data](https://www.kaggle.com/c/dogs-vs-cats/data)�link. The input size is 64x64 pixels RGB which is 3x64x64 in CHW format.
The model trained in this demo is used to classify images of cats and dogs. 25000 images dataset is used to train the model. The dataset can be downloaded using�[https://www.kaggle.com/c/dogs-vs-cats/data](https://www.kaggle.com/c/dogs-vs-cats/data)�link. The input size is 128x128 pixels RGB which is 3x128x128 in CHW format.

The code uses a sampledata header (sampledata.h) file to test a pre-defined input sample. The example also supports live capture from camera module and displays the image on the TFT LCD.

Expand Down Expand Up @@ -75,13 +75,13 @@ The PB1 (SW1) button is located as shown in picture bellow:

### Camera Mode

This mode uses OVM7692 camera module to capture an image in RGB888 format. Since the model is trained using 64x64 pixel image, the PCIF peripheral captures 64x64 pixel image and displays it on LCD.
This mode uses OVM7692 camera module to capture an image in RGB888 format. Since the model is trained using 128x128 pixel image, the PCIF peripheral captures 128x128 pixel image and displays it on LCD.

### Offline Mode

To operate in this mode, uncomment "#define USE\_SAMPLEDATA", defined in main.c.�

This mode uses a header file "sampledata.h" containing RGB image data and it should be included in the project to use it as an input to the cnn network.�
This mode uses a header file "sampledata.h" containing RGB image data and it should be included in the project to use it as an input to the CNN network.�

To create your own header file follow these steps:

Expand Down
22 changes: 13 additions & 9 deletions Examples/MAX78000/CNN/cats-dogs_demo/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ static uint8_t *rx_data = NULL;
void setup_dma_tft(uint32_t *src_ptr, uint16_t byte_cnt)
{
// TFT DMA
while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) {
;
}
while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) {}

MXC_DMA->ch[g_dma_channel_tft].status = MXC_F_DMA_STATUS_CTZ_IF; // Clear CTZ status flag
MXC_DMA->ch[g_dma_channel_tft].dst = (uint32_t)rx_data; // Cast Pointer
Expand Down Expand Up @@ -186,9 +184,7 @@ void setup_dma_tft(uint32_t *src_ptr, uint16_t byte_cnt)
/* **************************************************************************** */
void start_tft_dma(uint32_t *src_ptr, uint16_t byte_cnt)
{
while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) {
;
}
while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) {}

if (MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_CTZ_IF) {
MXC_DMA->ch[g_dma_channel_tft].status = MXC_F_DMA_STATUS_CTZ_IF;
Expand Down Expand Up @@ -400,8 +396,10 @@ int main(void)
Camera_Power(POWER_ON);
//MXC_Delay(300000);
printf("\n\nCats-vs-Dogs Feather Demo\n");
#else
#elif defined(BOARD_EVKIT_V1)
printf("\n\nCats-vs-Dogs Evkit Demo\n");
#else
printf("\n\nCats-vs-Dogs CAM02 Demo\n");
#endif

/* Enable cache */
Expand Down Expand Up @@ -463,7 +461,8 @@ int main(void)

#ifdef BOARD_EVKIT_V1
camera_write_reg(0x11, 0x1); // set camera clock prescaller to prevent streaming overflow
#else
#endif
#ifdef BOARD_FTHR_REVA
camera_write_reg(0x11, 0x0); // set camera clock prescaller to prevent streaming overflow
#endif

Expand All @@ -477,8 +476,10 @@ int main(void)
TFT_Print(buff, 20, 130, font_2, snprintf(buff, sizeof(buff), "PRESS PB1(SW1) TO START!"));
#endif

#if defined(BOARD_EVKIT_V1) || defined(BOARD_FTHR_REVA)
printf("********** Press PB1(SW1) to capture an image **********\r\n");
while (!PB_Get(0)) {}
#endif

#ifdef TFT_ENABLE
MXC_TFT_ClearScreen();
Expand Down Expand Up @@ -566,9 +567,12 @@ int main(void)

#ifdef ASCII_ART
asciiart((uint8_t *)input_0);
printf("********** Press PB1(SW1) to capture an image **********\r\n");
#endif

#if defined(BOARD_EVKIT_V1) || defined(BOARD_FTHR_REVA)
printf("********** Press PB1(SW1) to capture an image **********\r\n");
while (!PB_Get(0)) {}
#endif
}

return 0;
Expand Down
21 changes: 13 additions & 8 deletions Examples/MAX78000/CNN/cats-dogs_demo/project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@
# Add your config here!
# Uncomment the line below to build for the MAX78000FTHR
#BOARD=FTHR_RevA
# Uncomment the line below to build for the MAX78000CAM02
#BOARD = CAM02_RevA

$(info Note: This project is designed and tested for the OV7692 only.)
override CAMERA=OV7692
ifeq ($(BOARD),EvKit_V1)
CAMERA = OV7692
endif

ifeq ($(BOARD),FTHR_RevA)
CAMERA = OV7692
endif

ifeq ($(BOARD),CAM02_RevA)
CAMERA = GC0308
endif

# Set a higher optimization level. The increased performance
# is required for the CameraIF DMA code to work within the
Expand Down Expand Up @@ -46,9 +57,3 @@ endif
ifeq ($(BOARD),CAM01_RevA)
$(error ERR_NOTSUPPORTED: This project is not supported for the CAM01 board)
endif

ifeq ($(BOARD),CAM02_RevA)
$(error ERR_NOTSUPPORTED: This project is not supported for the CAM02 board)
endif


6 changes: 6 additions & 0 deletions Examples/MAX78000/ImgCapture/project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

# **********************************************************

# Note: To change the target board, see https://analogdevicesinc.github.io/msdk//USERGUIDE/#board-support-packages

# Project options:
# Set to 1 to enable, 0 to disable
CONSOLE = 1
Expand All @@ -28,6 +30,10 @@ ifeq ($(BOARD),CAM01_RevA)
CAMERA = HM0360_COLOR
endif

ifeq ($(BOARD),CAM02_RevA)
CAMERA = GC0308
endif

ifeq ($(BOARD),FTHR_RevA)
CAMERA = OV7692
endif
Expand Down

0 comments on commit 0038d43

Please sign in to comment.