broncho-vaxom

为了冬季避免感冒,尝试了一款名为泛福舒的高价预防药物,每天空腹服用一颗,连续十天为一疗程。虽然价格昂贵(148元十颗),但因其独特效果受到多人青睐。
部署运行你感兴趣的模型镜像
今天去医院买了个超贵的药,泛福舒, broncho-vaxom ,名字很好听,是感冒类的预防药,每天空腹吃一颗,连吃十颗就不会感冒了,神奇吧。不过148元十颗,是偶买过的最贵的药了。不过冬天来了,我超怕感冒,只有出血买了。我买这个药的时候,旁边还有好几个人买,药店一下子卖掉三盒,生意真好啊。 :arrow:

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

【无人机】基于改进粒子群算法的无人机路径规划研究[和遗传算法、粒子群算法进行比较](Matlab代码实现)内容概要:本文围绕基于改进粒子群算法的无人机路径规划展开研究,重点探讨了在复杂环境中利用改进粒子群算法(PSO)实现无人机三维路径规划的方法,并将其与遗传算法(GA)、标准粒子群算法等传统优化算法进行对比分析。研究内容涵盖路径规划的多目标优化、避障策略、航路点约束以及算法收敛性和寻优能力的评估,所有实验均通过Matlab代码实现,提供了完整的仿真验证流程。文章还提到了多种智能优化算法在无人机路径规划中的应用比较,突出了改进PSO在收敛速度和全局寻优方面的优势。; 适合人群:具备一定Matlab编程基础和优化算法知识的研究生、科研人员及从事无人机路径规划、智能优化算法研究的相关技术人员。; 使用场景及目标:①用于无人机在复杂地形或动态环境下的三维路径规划仿真研究;②比较不同智能优化算法(如PSO、GA、蚁群算法、RRT等)在路径规划中的性能差异;③为多目标优化问题提供算法选型和改进思路。; 阅读建议:建议读者结合文中提供的Matlab代码进行实践操作,重点关注算法的参数设置、适应度函数设计及路径约束处理方式,同时可参考文中提到的多种算法对比思路,拓展到其他智能优化算法的研究与改进中。
/* * File: gsnap.c * Author: Li XianJing <xianjimli@hotmail.com> * Brief: snap the linux mobile device screen. * * Copyright (c) 2009 Li XianJing <xianjimli@hotmail.com> * * Licensed under the Academic Free License version 2.1 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * History: * ================================================================ * 2009-08-20 Li XianJing <xianjimli@hotmail.com> created * 2011-02-28 Li XianJing <xianjimli@hotmail.com> suppport RGB888 framebuffer. * 2011-04-09 Li XianJing <xianjimli@hotmail.com> merge figofuture's png output. * ref: http://blog.chinaunix.net/space.php?uid=15059847&do=blog&cuid=2040565 * */ #include <png.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <jpeglib.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include <linux/fb.h> #include <linux/kd.h> struct _FBInfo; typedef struct _FBInfo FBInfo; typedef int (*UnpackPixel)(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b); struct _FBInfo { int fd; UnpackPixel unpack; unsigned char *bits; struct fb_fix_screeninfo fi; struct fb_var_screeninfo vi; }; #define fb_width(fb) ((fb)->vi.xres) #define fb_height(fb) ((fb)->vi.yres) #define fb_bpp(fb) ((fb)->vi.bits_per_pixel>>3) #define fb_size(fb) ((fb)->vi.xres * (fb)->vi.yres * fb_bpp(fb)) static int fb_unpack_rgb565(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b) { unsigned short color = *(unsigned short*)pixel; *r = ((color >> 11) & 0xff) << 3; *g = ((color >> 5) & 0xff) << 2; *b = (color & 0xff )<< 3; return 0; } static int fb_unpack_rgb24(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b) { *r = pixel[fb->vi.red.offset>>3]; *g = pixel[fb->vi.green.offset>>3]; *b = pixel[fb->vi.blue.offset>>3]; return 0; } static int fb_unpack_argb32(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b) { *r = pixel[fb->vi.red.offset>>3]; *g = pixel[fb->vi.green.offset>>3]; *b = pixel[fb->vi.blue.offset>>3]; return 0; } static int fb_unpack_none(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b) { *r = *g = *b = 0; return 0; } static void set_pixel_unpacker(FBInfo* fb) { if(fb_bpp(fb) == 2) { fb->unpack = fb_unpack_rgb565; } else if(fb_bpp(fb) == 3) { fb->unpack = fb_unpack_rgb24; } else if(fb_bpp(fb) == 4) { fb->unpack = fb_unpack_argb32; } else { fb->unpack = fb_unpack_none; printf("%s: not supported format.\n", __func__); } return; } static int fb_open(FBInfo* fb, const char* fbfilename) { fb->fd = open(fbfilename, O_RDWR); if (fb->fd < 0) { fprintf(stderr, "can't open %s\n", fbfilename); return -1; } if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &fb->fi) < 0) goto fail; if (ioctl(fb->fd, FBIOGET_VSCREENINFO, &fb->vi) < 0) goto fail; fb->bits = mmap(0, fb_size(fb), PROT_READ | PROT_WRITE, MAP_SHARED, fb->fd, 0); if (fb->bits == MAP_FAILED) goto fail; printf("---------------framebuffer---------------\n"); printf("%s: \n width : %8d\n height: %8d\n bpp : %8d\n r(%2d, %2d)\n g(%2d, %2d)\n b(%2d, %2d)\n", fbfilename, fb_width(fb), fb_height(fb), fb_bpp(fb), fb->vi.red.offset, fb->vi.red.length, fb->vi.green.offset, fb->vi.green.length, fb->vi.blue.offset, fb->vi.blue.length); printf("-----------------------------------------\n"); set_pixel_unpacker(fb); return 0; fail: printf("%s is not a framebuffer.\n", fbfilename); close(fb->fd); return -1; } static void fb_close(FBInfo* fb) { munmap(fb->bits, fb_size(fb)); close(fb->fd); return; } static int snap2jpg(const char * filename, int quality, FBInfo* fb) { int row_stride = 0; FILE * outfile = NULL; JSAMPROW row_pointer[1] = {0}; struct jpeg_error_mgr jerr; struct jpeg_compress_struct cinfo; memset(&jerr, 0x00, sizeof(jerr)); memset(&cinfo, 0x00, sizeof(cinfo)); cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); if ((outfile = fopen(filename, "wb+")) == NULL) { fprintf(stderr, "can't open %s\n", filename); return -1; } jpeg_stdio_dest(&cinfo, outfile); cinfo.image_width = fb_width(fb); cinfo.image_height = fb_height(fb); cinfo.input_components = 3; cinfo.in_color_space = JCS_RGB; jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, quality, TRUE); jpeg_start_compress(&cinfo, TRUE); row_stride = fb_width(fb) * 2; JSAMPLE* image_buffer = malloc(3 * fb_width(fb)); while (cinfo.next_scanline < cinfo.image_height) { int i = 0; int offset = 0; unsigned char* line = fb->bits + cinfo.next_scanline * fb_width(fb) * fb_bpp(fb); for(i = 0; i < fb_width(fb); i++, offset += 3, line += fb_bpp(fb)) { fb->unpack(fb, line, image_buffer+offset, image_buffer + offset + 1, image_buffer + offset + 2); } row_pointer[0] = image_buffer; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } jpeg_finish_compress(&cinfo); fclose(outfile); jpeg_destroy_compress(&cinfo); return 0; } //Ref: http://blog.chinaunix.net/space.php?uid=15059847&do=blog&cuid=2040565 static int snap2png(const char * filename, int quality, FBInfo* fb) { FILE *outfile; if ((outfile = fopen(filename, "wb+")) == NULL) { fprintf(stderr, "can't open %s\n", filename); return -1; } /* prepare the standard PNG structures */ png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0); png_infop info_ptr = png_create_info_struct(png_ptr); /* setjmp() must be called in every function that calls a PNG-reading libpng function */ if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); fclose(outfile); return -1; } /* initialize the png structure */ png_init_io(png_ptr, outfile); // int width = 0; int height = 0; int bit_depth = 8; int color_type = PNG_COLOR_TYPE_RGB; int interlace = 0; width = fb_width(fb); height = fb_height(fb); png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type, (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); /* write the file header information */ png_write_info(png_ptr, info_ptr); png_bytep row_pointers[height]; png_byte* image_buffer = malloc(3 * width); int i = 0; int j = 0; unsigned char* line = NULL; for( ; i < height; i++ ) { line = (char*)fb->bits + i * width * fb_bpp(fb); for(j = 0; j < width; j++, line += fb_bpp(fb)) { int offset = j * 3; fb->unpack(fb, line, image_buffer+offset, image_buffer+offset+1, image_buffer+offset+2); } row_pointers[i] = image_buffer; png_write_rows(png_ptr, &row_pointers[i], 1); } png_destroy_write_struct(&png_ptr, &info_ptr); fclose(outfile); return 0; } int main(int argc, char* argv[]) { FBInfo fb; const char* filename = NULL; const char* fbfilename = NULL; if(argc != 3) { printf("\nUsage: %s [jpeg|png file] [framebuffer dev]\n", argv[0]); printf("Example: %s fb.jpg /dev/fb0\n", argv[0]); printf("-----------------------------------------\n"); printf("Powered by broncho(www.broncho.cn)\n\n"); return 0; } filename = argv[1]; fbfilename = argv[2]; memset(&fb, 0x00, sizeof(fb)); if (fb_open(&fb, fbfilename) == 0) { if(strstr(filename, ".png") != NULL) { snap2png(filename, 100, &fb); } else { snap2jpg(filename, 100, &fb); } fb_close(&fb); } return 0; } 以上代码使用/dev/fb0实现截图功能,请重构,使用/dev/dri/card0实现截图功能。
11-25
要将代码从使用 `/dev/fb0` 改为使用 `/dev/dri/card0`,需要理解两者的差异: - **`/dev/fb0`** 是传统的 Framebuffer 接口,通过 `fb.h` 提供的系统调用(如 `ioctl`)来读取屏幕内容。 - **`/dev/dri/card0`** 是 DRM (Direct Rendering Manager) 的接口,提供了更现代、硬件加速的图形访问方式。它通常用于支持 3D 图形和更高级别的显示管理。 ### 修改步骤 1. **移除 Framebuffer 相关头文件** - 删除或注释掉与 Framebuffer 有关的定义,比如 `#include <linux/fb.h>` 和 `#include <linux/kd.h>`。 2. **添加 DRM 头文件** - 包括必要的 DRM 头文件,例如: ```c #include <xf86drm.h> #include <xf86drmMode.h> ``` 3. **修改结构体定义** - 将 `FBInfo` 替换为新的结构体,用来保存 DRM 设备的信息,例如连接句柄、模式信息等。 - 示例结构体: ```c typedef struct _DRMInfo { int fd; // DRM 设备文件描述符 drmModeRes* res; // 显示资源 drmModeConnector* conn; // 连接器 drmModeEncoder* enc; // 编码器 drmModeCrtc* crtc; // CRT 控制器 unsigned char* bits; // 显存映射地址 size_t buffer_size; // 显存大小 } DRMInfo; ``` 4. **初始化 DRM 设备** - 使用 `drmOpen` 打开设备。 - 使用 `drmModeGetResources` 获取资源。 - 查找有效的连接器、编码器和 CRTC。 - 设置 CRTC 的分辨率。 - 映射显存 (`mmap`)。 5. **读取像素数据** - 通过 `mmap` 映射的显存地址读取像素数据,并根据当前的像素格式进行解析。 6. **释放资源** - 在程序结束时,记得释放所有 DRM 资源并关闭设备。 7. **适配 PNG/JPG 输出函数** - 如果 DRM 的像素格式不同(例如 ARGB8888),需要调整 `snap2jpg` 和 `snap2png` 中的像素解包逻辑。 --- 以下是重构后的代码框架示例: ```c #include <xf86drm.h> #include <xf86drmMode.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> typedef struct _DRMInfo { int fd; drmModeRes* res; drmModeConnector* conn; drmModeEncoder* enc; drmModeCrtc* crtc; unsigned char* bits; size_t buffer_size; } DRMInfo; static void drm_open(DRMInfo* info, const char* devname) { info->fd = drmOpen("i915", NULL); // 根据实际驱动选择 if (info->fd < 0) { perror("Failed to open DRM device"); exit(EXIT_FAILURE); } info->res = drmModeGetResources(info->fd); if (!info->res) { perror("Failed to get DRM resources"); exit(EXIT_FAILURE); } for (int i = 0; i < info->res->connector_count; ++i) { info->conn = drmModeGetConnector(info->fd, info->res->connectors[i]); if (info->conn && info->conn->connection == DRM_MODE_CONNECTED) { break; } drmModeFreeConnector(info->conn); } info->enc = drmModeGetEncoder(info->fd, info->conn->encoder_id); info->crtc = drmModeGetCrtc(info->fd, info->enc->crtc_id); info->buffer_size = info->crtc->width * info->crtc->height * 4; // 假设是 ARGB8888 info->bits = mmap(0, info->buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, info->fd, info->crtc->offset); if (info->bits == MAP_FAILED) { perror("Failed to mmap"); exit(EXIT_FAILURE); } } static void drm_close(DRMInfo* info) { munmap(info->bits, info->buffer_size); drmModeFreeCrtc(info->crtc); drmModeFreeEncoder(info->enc); drmModeFreeConnector(info->conn); drmModeFreeResources(info->res); close(info->fd); } ``` ---
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值