본문 바로가기

ESP32cam 스트리밍 문제 해결 본문

개인 프로젝트 and 논문/딥러닝 자율주행 장난감 만들기

ESP32cam 스트리밍 문제 해결

jaegomhoji 2023. 6. 13. 10:29

ESP32cam 기본 코드 예제로 연결하면, 굉장히 스트리밍이 느리다. 

https://randomnerdtutorials.com/esp32-cam-ov2640-camera-settings/

 

Change ESP32-CAM OV2640 Camera Settings: Brightness, Resolution, Quality, Contrast, and More | Random Nerd Tutorials

This guide shows how to change the ESP32-CAM OV2640 camera settings such as contrast, brightness, resolution, quality, saturation and more using Arduino IDE.

randomnerdtutorials.com

카메라 설정을(화질 등) 바꿔봐도 똑같은 문제가 지속됨.

 

아직 ESP32-cam에 대해서 자료가 많지 않지만, 스트리밍 안된다, 느리다 검색하면 git issue가 상단에 노출된다. 

https://github.com/espressif/arduino-esp32/issues/4655

 

Extremely poor performance on ESP32-CAM board · Issue #4655 · espressif/arduino-esp32

Hardware: Board: ESP32-CAM (Generic, using ESP32-S module) Core Installation version: 1.0.4 IDE name: Arduino IDE Flash Frequency: Default PSRAM enabled: Unsure (most likely yes, IPS6404LSO) Upload...

github.com

 

많은 문제들이 있었지만, 이 이슈를 등록한 사람도 나와 같은 문제를 겪었다. 

1. 어떤 셋팅에서도 성능이 안나옴

2. 블랙 스크린 

3. 프레임 드랍 

4. 딜레이  등등...

 

ESP-32cam 모델에 따라 다르겠지만, 안테나 문제라는 사람도 있고, 데이터 전송 방식의 문제라는 사람도 있었다. 

본인이 가지고 있는 모델은 안테나가 없는 모듈(위 이미지)이라서 일단 제외했다. 

 

아까 이슈를 확인하다보면, 고맙게도 누군가 만들어 놓은 코드가 있다. 

https://github.com/arkhipenko/esp32-cam-mjpeg

해당 코드를 사용한다. 

 

아두이노 IDE로 불러온 후, 1) home_wifi_multi.h <- 헤더파일 하나 생성해주고 

터미널

touch home_wifi_multi.h 

sudo chmod -R 777 filename

sudo nano filename 

 

파일내용 #ifndef SSID1
#define SSID1 "your wifi name"
#endif 

#ifndef PWD1
#define PWD1 "your wifi password"
#endif 

 

2) esp32_camera_mjpeg.ino <- 파일 수정해준다. 

    2-1) 카메라 모델 변경 ( 본인 모델에 맞게 ) 

#define CAMERA_MODEL_AI_THINKER

   2-2) 셋업 설정에서 xclk_feq_hz 20,000,000 -> 8mhz로 변경 

config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 8000000;
config.pixel_format = PIXFORMAT_JPEG;

 

3)  만약 아두이노에서 컴파일이 안되면, 파일을 못읽어서 그럴 확률이 높으니, 

밖의 파일들을 모두 안쪽에 넣어줌. 

그럼 아래 파일들이 모두 같은 level에 있음 

-src(폴더)

-.h(파일들)

-.ino(파일들)

 

4) 이후 개선 확인 

 

해결 전 
해결 이후 

이제는 더이상 답답하지 않다.

 

 

 

 

 

 

 

 

 

Comments