-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make esp32-cam as submodule #34
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: huangzzk <[email protected]>
Signed-off-by: huangzzk <[email protected]>
Would love to see this PR merged. Also, I'm having trouble with jeanlemotan's master branch:
while the PR author's orangepi branch works out of the box for my ESP32-CAM. |
And also, how to use your project without WiFi? I was looking for a solution for fast video recording to an SD card, that's how I came upon this project and the fork. The video won't be streamed. |
Hi, the root cause is that there are no enough ram to allocate DMA buffer.
and origin project is:
also, if you want to use sd recording, you can simply set |
@Ncerzzk thanks for pinpoiting the relevant changes. I'll try to checkout these changes and see if I manage to run jeanlemotan's code with them.
I know. But as I said, WiFi jams my magnetic sensor measurements if put in close proximity: the magnetic field measurement noise increase up to 2-3X times if WiFi is on! Even broadcasting ping packets... So I'd like to turn it off completely. This will also save the juice to spend CPU & DRAM resources on other tasks. |
got it. in my orangepi3lts branch, I have do some cleanning up and move large part of wifi relation to wifi.c and wifi.h, but I have not tried to close wifi yet.
…---Original---
From: "Danylo ***@***.***>
Date: Sun, Mar 5, 2023 14:21 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [jeanlemotan/esp32-cam-fpv] make esp32-cam as submodule (PR #34)
@Ncerzzk thanks for pinpoiting the relevant changes. I'll try to checkout these changes and see if I manage to run jeanlemotan's code with them.
also, if you want to use sd recording, you can simply set s_ground2air_config_packet. dvr_record = true
I know. But as I said, WiFi jams my magnetic sensor measurements if put in close proximity: the magnetic field measurement noise increase up to 2-3X times if WiFi is on! Even broadcasting ping packets... So I'd like to turn it off completely. This will also save the juice to spend CPU & DRAM resources on other tasks.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Thanks a lot for this PR. I will try this weekend to test it on my setup and merge it afterwards. |
Regarding disabling the wifi, this should be relatively easy to configure. I can add some defines to completely disable all the wifi functionality. |
That would be great, thanks. |
But firstly I'd like to see Ncerzzk's changes he mentioned
here. It's not straightforward and the diff is shown only partially. |
Hi, these changes are done in https://github.com/Ncerzzk/esp32-camera/tree/for-esp-cam-fpv |
Ah I see, so the changes come from Espressif's fork, not this repo. Got it. |
@Ncerzzk so I ran your code in https://github.com/Ncerzzk/esp32-camera/tree/for-esp-cam-fpv (take_picture example) and got
although as I said the camera is detected in orangepi branch of this project. |
@dizcza the for-esp-cam-fpv branch is only target for wifi sending. the main hack is: this hack add a data_available_callback, and the data from camera will not be saved to frame buffer, so the example could not run. |
All right, I did that: #include <esp_log.h>
#include <esp_system.h>
#include <sys/param.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_timer.h"
#include "esp_camera.h"
#include "bsp.h"
#include "sdcard.h"
#include "sdcard_record.h"
// support IDF 5.x
#ifndef portTICK_RATE_MS
#define portTICK_RATE_MS portTICK_PERIOD_MS
#endif
/* ESP32-CAM AITHINKER START */
#define CAM_PIN_PWDN 32
#define CAM_PIN_RESET -1 //software reset will be performed
#define CAM_PIN_XCLK 0
#define CAM_PIN_SIOD 26
#define CAM_PIN_SIOC 27
#define CAM_PIN_D7 35
#define CAM_PIN_D6 34
#define CAM_PIN_D5 39
#define CAM_PIN_D4 36
#define CAM_PIN_D3 21
#define CAM_PIN_D2 19
#define CAM_PIN_D1 18
#define CAM_PIN_D0 5
#define CAM_PIN_VSYNC 25
#define CAM_PIN_HREF 23
#define CAM_PIN_PCLK 22
static const char *TAG = "main";
size_t my_data_available_callback(void * cam_obj,const uint8_t* data, size_t count, bool last) {
static FILE *f = NULL;
static char fname[64];
static uint32_t frame_id = 0;
static uint8_t framebuffer_static[30 * 1024];
const int64_t millis = esp_timer_get_time() / 1000;
if (f == NULL) {
snprintf(fname, sizeof(fname), "IMG-%06lu-%lld.JPEG", frame_id++, millis);
f = sdcard_record_open_file_once_silent(fname, "w");
}
memcpy(framebuffer_static, data, count);
fwrite(framebuffer_static, sizeof(uint8_t), count, f);
if (frame_id % 10 == 0) {
float fps = 1000.0 * frame_id / millis;
ESP_LOGI(TAG, "FPS %.1f", fps);
}
if (last) {
fclose(f);
f = NULL;
ESP_LOGI(TAG, "cb %zu bytes last", count);
}
return count;
}
static const camera_config_t camera_config = {
.pin_pwdn = CAM_PIN_PWDN,
.pin_reset = CAM_PIN_RESET,
.pin_xclk = CAM_PIN_XCLK,
.pin_sccb_sda = CAM_PIN_SIOD,
.pin_sccb_scl = CAM_PIN_SIOC,
.pin_d7 = CAM_PIN_D7,
.pin_d6 = CAM_PIN_D6,
.pin_d5 = CAM_PIN_D5,
.pin_d4 = CAM_PIN_D4,
.pin_d3 = CAM_PIN_D3,
.pin_d2 = CAM_PIN_D2,
.pin_d1 = CAM_PIN_D1,
.pin_d0 = CAM_PIN_D0,
.pin_vsync = CAM_PIN_VSYNC,
.pin_href = CAM_PIN_HREF,
.pin_pclk = CAM_PIN_PCLK,
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
.xclk_freq_hz = 20000000,
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
.pixel_format = PIXFORMAT_JPEG, //YUV422,GRAYSCALE,RGB565,JPEG
.frame_size = FRAMESIZE_VGA, //QQVGA-UXGA, For ESP32, do not use sizes above QVGA when not JPEG. The performance of the ESP32-S series has improved a lot, but JPEG mode always gives better frame rates.
.jpeg_quality = 12, //0-63, for OV series camera sensors, lower number means higher quality
.fb_count = 5, //When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
.grab_mode = CAMERA_GRAB_WHEN_EMPTY,
.data_available_callback = my_data_available_callback
};
static esp_err_t init_camera()
{
//initialize the camera
BSP_SOFTCHECK(esp_camera_init(&camera_config));
return ESP_OK;
}
void app_main()
{
sdcard_mount_mmc();
sdcard_record_create_dir("esp32cam");
sdcard_log_start();
if (ESP_OK != init_camera()) {
return;
}
} Logs:
But it's veeery slow compared to Espressif's solution. I also don't know whether the An example is needed. |
hmm, let's go back from the beginning. in this project or my for-esp-cam-fpv branch, we don't need frame buffer, because we send the data to wifi/sd processes at each dma recv intterrupt. come back to your code, if you still want to use the hacked esp32-camera: also, you should handle the start of jpeg(refer main.cpp) , or the data you write may not a valid jpeg. |
I see, so I misinterpreted the project description:
I thought this project comes up with some unverified hacks that speed up the camera capture acquisition process at expense of providing less support (platform-wise, different camera, different ESP-IDF, etc.) and potential data corruption (at higher speed I expect to see data loss in the captured frames). If this project does not speed up camera capture process by any means or doesn't provide alternative ways to dump the data in callbacks that further decrease latency (like in callbacks of yours), I'll stick to Espressif's original version. |
Hi, this pr aims to make esp32-cam as git submodule.
advantages:
Thank you. Feel free to comment