C 如何合并/馈送两个uint8\t缓冲区?
嘿,很抱歉这个新手问题,但我想我只是错过了一些明显的东西。。。我很乐意得到一些关于这方面的指导:C 如何合并/馈送两个uint8\t缓冲区?,c,arduino,esp32,uint8t,C,Arduino,Esp32,Uint8t,嘿,很抱歉这个新手问题,但我想我只是错过了一些明显的东西。。。我很乐意得到一些关于这方面的指导: esp_camera.h的内联文档: /** * @brief Data structure of camera frame buffer */ typedef struct { uint8_t * buf; /*!< Pointer to the pixel data */ size_t len; /*!<
esp_camera.h的内联文档:
/**
* @brief Data structure of camera frame buffer
*/
typedef struct {
uint8_t * buf; /*!< Pointer to the pixel data */
size_t len; /*!< Length of the buffer in bytes */
size_t width; /*!< Width of the buffer in pixels */
size_t height; /*!< Height of the buffer in pixels */
pixformat_t format; /*!< Format of the pixel data */
} camera_fb_t;
获取帧缓冲区的代码
camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK;
fb = esp_camera_fb_get(); // framebuffer in grayscale
并将fb缓冲区输入imagebuffer
int w, h;
int i, count;
uint8_t *imagebuffer = quirc_begin(qr, &w, &h);
//Feed 'fb' into 'imagebuffer' somehow?
//-------------------------------
// ----- DUMMY CODE?! not the proper way? ----
imagebuffer = fb->buf; //fb's own buf field, holding the pixel data
//Comment from quirc below:
/* Fill out the image buffer here.
* 'imagebuffer' is a pointer to a w*h bytes.
* One byte per pixel, w pixels per line, h lines in the buffer.
*/
//
quirc_end(qr);
quirc的内联评论文件如下:
/* These functions are used to process images for QR-code recognition.
* quirc_begin() must first be called to obtain access to a buffer into
* which the input image should be placed. Optionally, the current
* width and height may be returned.
*
* After filling the buffer, quirc_end() should be called to process
* the image for QR-code recognition. The locations and content of each
* code may be obtained using accessor functions described below.
*/
uint8_t *quirc_begin(struct quirc *q, int *w, int *h);
void quirc_end(struct quirc *q);
我已经看过了代码、源文件等,但作为一个新手,我不知道如何将一个合并到另一个
有人能给我指一下正确的方向吗?我并不讨厌浏览大量的代码,但我对C语言缺乏经验是这里的问题:谢谢 图书馆的作者很友好地解释了这一点, 在此处发布代码答案,因为它可能会帮助其他人:
int w, h;
int i, count;
uint8_t *buff = quirc_begin(qr, &w, &h);
//
int total_pixels = w * h;
for (int i = 0; i < total_pixels; i++) {
// grab a pixel from your source image at element i
// convert it somehow, then store it
buff[i] = fb->buf[i]; //?
}
//
quirc_end(qr);
count = quirc_count(qr);
Serial.println("count found codes:");
Serial.println(count);
intw,h;
int i,计数;
uint8\u t*buff=开始(qr、w和h);
//
int总像素=w*h;
对于(int i=0;ibuf[i];/?
}
//
quirc_端(qr);
计数=quirc\U计数(qr);
Serial.println(“计数找到的代码:”);
序列号.println(计数);
C还是C++?合并到底是什么?结果应该是什么?什么是照相机?什么应该
buf=fb代码>表示?尝试将其清除一点。整个事情是关于把fb的数据输入buf。因此,据我所知,它们不是简单的变量,我胡乱猜测,仅仅做buf=fb不会起作用:SLook upmemcpy()
@yhyrcanus这就是你的意思吗<代码>memcpy(imagebuffer,fb->buf,strlen(fb->buf)+1)
这是将一个缓冲区“输入”到另一个缓冲区的正确方法吗?不是正确的方法:从'uint8_t*{aka unsigned char*}到'const char*'[-fppermissive]的无效转换。
我真的觉得我有点力不从心,澄清我模棱两可的评论:):你可以用memcpy(buff,fb->buf,total\u像素)替换循环
我想知道你是否可以用fb->len
代替计算总像素。我不确定这是否会在过程中得到设置。我会检查一下,上面的代码是有效的,但总有改进的余地:D
int w, h;
int i, count;
uint8_t *buff = quirc_begin(qr, &w, &h);
//
int total_pixels = w * h;
for (int i = 0; i < total_pixels; i++) {
// grab a pixel from your source image at element i
// convert it somehow, then store it
buff[i] = fb->buf[i]; //?
}
//
quirc_end(qr);
count = quirc_count(qr);
Serial.println("count found codes:");
Serial.println(count);