1.rgb raw数据准备
利用python将jpg里面的rgb raw数据提取出来。
import cv2
# 读取 JPG 图像
image_path = '1.jpg'
image = cv2.imread(image_path)#imread读出来的顺序是BGR
print("image shape:",image.shape)
# 将图像由BGR转换为 RGB 数据
rgb_data = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# cv2.imwrite() function is used to save the RGB data to a file.
# The output_path variable specifies the path and filename for the output file, which should have a JPG extension
#output_path = 'output'
#cv2.imwrite(output_path,rgb_data)
# 将RGB存为RAW数据
output_path = 'rgb.raw'
rgb_data.tofile(output_path)
1.1 查看raw数据

2.代码实现

2.1 cjson库:https://github.com/DaveGamble/cJSON
2.2 base64库:https://github.com/jwerle/b64.c
2.3 工程目录

#include <stdio.h>
#include

本文介绍了如何使用Python的OpenCV库从jpg图像中提取RGB原始数据,然后使用cJSON和base64库进行编码和解码的过程。
最低0.47元/天 解锁文章
671

被折叠的 条评论
为什么被折叠?



