show me the code
一个缩放一个合并,读者自己读吧
/*
lrgb: input 24bits rgb buffer
srgb: output 24bits rgb buffer
width: input width
height: input height
xscale: changed vector
yscale: changed vector
*/
//注意:钱波
//无论是正的还是反的都没有关系,不要在意,因为输入是一副图像,不要忘了这一点
uint8_t * scale(unsigned char *inrgb, int width, int height,
float xscale, //摄像头画面x轴缩放
float yscale, //摄像头画面Y轴缩放
int &outw,
int &outh,
uint8_t * deskrgb, //叠加的大画布
int outrgbpitch //大画布的pitch,一行占用像素,rgb24是 w*3
)
{
int in = 0, out = 0;
int ox, oy; //the pixel site is after changed
int rx, ry; //the pixel site is before changed
int temp = 0; //turn site(x,y) to memory storage
outw = width * xscale; //after changed width
outh = height * yscale; //after changed height
int pitch = outw * outh * 3;
int memlen = pitch * outh;
unsigned char *outrgb = new uint8_t[memlen];
//rx = ox/xscale + 0.5;// out--to--input
//ry = oy/yscale + 0.5;// out--to--input
for (oy = 0; oy = height)
ry--;
temp = ry * width * 3;//origion pixel site of which width
for (ox = 0; ox = width)
rx--;
in = temp + rx * 3;//change site(x,y) to storage
outrgb[out + 0] = inrgb[in + 0];
outrgb[out + 1] = inrgb[in + 1];
outrgb[out + 2] = inrgb[in + 2];
out += 3;
}
//outrgb += outrgbpitch;
}
return outrgb;
}
//合并rgb24,
//如果是摄像头是4:3 则取摄像头画面的16:9
//注意,came画面是反的,desk是正的,所以,算法要倒算
void merge_rgb(uint8_t *desk, int sw, int sh, uint8_t *came,
int cw, //摄像头画面宽度
int ch, //摄像头画面高度
float xscale, //摄像头画面x轴缩放
float yscale) //摄像头画面y轴缩放
{
int pitch = cw * 3;
uint8_t * src = came + pitch *(ch - 1); //camera 的 最后一行
//把画面移动到右上角,离顶50像素,离右边20像素
int right_distance = cw*xscale * 3 + 20 * 3;
uint8_t * dst = desk + (sw * 3 * 50 - right_distance);
//裁剪16:9
int tempdh = cw * 9 / 16;
if (tempdh > ch)
tempdh = ch;
uint8_t *src1 = came + pitch *(ch - tempdh);
int outw, outh;
uint8_t * out = scale(src1, cw, tempdh, xscale, yscale, outw, outh, desk, sw * 3);
src = out + outw * 3 * (outh - 1);
//return;
//取其中的dw ,dh 的小画面
//开始缩放,直接内存开始读取
//
//把画面移动到中间位置
//uint8_t * dst = desk + sw * 3 / 2 - dw * 3 / 2;
//omp_set_num_threads(4);
//#pragma omp parallel
//{
//#pragma omp for
for (int i = 0; i
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?