关于CCSv5 Debug下image功能使用

本文介绍了如何在CCSv5环境下利用image功能显示图像,包括从MATLAB提取图像数据,生成.bmp文件,然后将数据存储到内存中,并在CCS中配置显示。作者分享了整个过程,包括遇到的问题和解决方法,以及YUV格式图像的显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在网上搜索各类文章在不断尝试下总算能够利用image显示图像。写下该篇文章一为记录,二为交流。

目前是学习DSP菜鸟,学习芯片TMS320DM6437。CCS版本为5.4.0

文中蓝色字体有具体的文件在我的资源中:http://download.youkuaiyun.com/detail/liu1guo2qiang3/7866091

整体思路:虽有硬件平台不过对VPFE模块不熟悉,以及主要还是想利用image工具完成显示。为方便以后调试。

1.存储图像数据至内存中

2.配置image的properties显示图像


过程:

开始搜到比较实用的文章:“CCS图像处理仿真程序,步骤详细”

原文网址:http://blog.163.com/lhf_alex/blog/static/1641091672010102810314785/

在这篇文章中主要参考了利用MATLAB提取图像数据的程序。我也参考过其他文章,不过不能直接应用,执行过程中有错误。

不想再MATLAB上深究的,果断选取有用的。

Matlab程序:Get_image.m

clear   
clc
[RGB,map]=imread('.\zz.bmp');  %共有320*240=76800个点
H=RGB;

r=H(:,:,1);
g=H(:,:,2);
b=H(:,:,3); 
  [M,N]=size(r);
 for i=1:

#include <stdio.h> #include <stdlib.h> #pragma pack(push, 1) typedef struct { unsigned short bfType; unsigned int bfSize; unsigned short bfReserved1; unsigned short bfReserved2; unsigned int bfOffBits; } BITMAPFILEHEADER; typedef struct { unsigned int biSize; unsigned int biWidth; unsigned int biHeight; unsigned short biPlanes; unsigned short biBitCount; unsigned int biCompression; unsigned int biSizeImage; unsigned int biXPelsPerMeter; unsigned int biYPelsPerMeter; unsigned int biClrUsed; unsigned int biClrImportant; } BITMAPINFOHEADER; #pragma pack(pop) // C6000兼容的周期计数函数 unsigned long long get_cycle_count() { unsigned int tsch, tscl; asm(" mvc .s2 TSCH, %0" : "=r"(tsch)); asm(" mvc .s2 TSCL, %0" : "=r"(tscl)); return ((unsigned long long)tsch << 32) | tscl; } int main(void) { const int width = 768, height = 576; const int sizeImage = width * height * 3; const int iterations = 1000; const char *src1_path = "HazyDay1.bmp"; const char *src2_path = "HazyDay2.bmp"; const char *dst_path = "jieguo.bmp"; printf("Starting image processing on C6000 DSP...\n"); printf("Image size: %dx%d, Iterations: %d\n", width, height, iterations); FILE *src1 = fopen(src1_path, "rb"); FILE *src2 = fopen(src2_path, "rb"); FILE *dst = fopen(dst_path, "wb"); if (!src1 || !src2 || !dst) { printf("Error opening files\n"); if (src1) fclose(src1); if (src2) fclose(src2); if (dst) fclose(dst); return -1; } BITMAPFILEHEADER fileHeader; BITMAPINFOHEADER infoHeader; if (fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, src1) != 1 || fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, src1) != 1) { printf("Error reading BMP headers\n"); fclose(src1); fclose(src2); fclose(dst); return -1; } unsigned char *img1 = (unsigned char *)malloc(sizeImage); unsigned char *img2 = (unsigned char *)malloc(sizeImage); unsigned char *result = (unsigned char *)malloc(sizeImage); if (!img1 || !img2 || !result) { printf("Memory allocation failed\n"); free(img1); free(img2); free(result); fclose(src1); fclose(src2); fclose(dst); return -1; } fseek(src1, fileHeader.bfOffBits, SEEK_SET); fseek(src2, fileHeader.bfOffBits, SEEK_SET); fread(img1, 1, sizeImage, src1); fread(img2, 1, sizeImage, src2); unsigned long long start_cycles, end_cycles; double total_time_3ch = 0, total_time_1ch = 0; int i, iter; // ================= 三通道同时处理 ================= printf("Running 3-channel method...\n"); start_cycles = get_cycle_count(); for (iter = 0; iter < iterations; iter++) { unsigned char *p1 = img1; unsigned char *p2 = img2; unsigned char *res = result; for (i = 0; i < sizeImage; i++) { *res++ = (*p1++ + *p2++) >> 1; } } end_cycles = get_cycle_count(); total_time_3ch = (double)(end_cycles - start_cycles); // ================= 单通道分别处理 ================= printf("Running 1-channel method...\n"); start_cycles = get_cycle_count(); for (iter = 0; iter < iterations; iter++) { for (i = 0; i < sizeImage; i += 3) { result[i] = (img1[i] + img2[i]) >> 1; result[i+1] = (img1[i+1] + img2[i+1]) >> 1; result[i+2] = (img1[i+2] + img2[i+2]) >> 1; } } end_cycles = get_cycle_count(); total_time_1ch = (double)(end_cycles - start_cycles); // 输出结果 printf("\nProcessing Time Comparison (after %d iterations):\n", iterations); printf("3-Channel Method:\n"); printf(" Total cycles: %.0f\n", total_time_3ch); printf(" Average cycles: %.0f\n", total_time_3ch/iterations); printf("1-Channel Method:\n"); printf(" Total cycles: %.0f\n", total_time_1ch); printf(" Average cycles: %.0f\n", total_time_1ch/iterations); if (total_time_1ch > 0 && total_time_3ch > 0) { double improvement = (total_time_1ch - total_time_3ch) / total_time_1ch * 100; printf("Efficiency Improvement: %.2f%% (%s method is faster)\n", fabs(improvement), improvement > 0 ? "3-channel" : "1-channel"); } // 写入结果 fwrite(&fileHeader, sizeof(BITMAPFILEHEADER), 1, dst); fwrite(&infoHeader, sizeof(BITMAPINFOHEADER), 1, dst); fseek(dst, fileHeader.bfOffBits, SEEK_SET); fwrite(result, 1, sizeImage, dst); // 释放资源 free(img1); free(img2); free(result); fclose(src1); fclose(src2); fclose(dst); return 0; } 为什么有下面的报错 **** Build of configuration Debug for project lab_03_app **** "G:\\ccs\\CCS5.5.0.00077_win32\\ccsv5\\utils\\bin\\gmake" -k all 'Building file: ../main.c' 'Invoking: C6000 Compiler' "G:/ccs/CCS5.5.0.00077_win32/ccsv5/tools/compiler/c6000_7.4.4/bin/cl6x" -mv6740 --abi=coffabi -g --include_path="G:/ccs/CCS5.5.0.00077_win32/ccsv5/tools/compiler/c6000_7.4.4/include" --display_error_number --diag_warning=225 --diag_wrap=off --preproc_with_compile --preproc_dependency="main.pp" "../main.c" "../main.c", line 31: error #18: expected a ")" "../main.c", line 32: error #18: expected a ")" "../main.c", line 33: warning #551-D: variable "tsch" is used before its value is set "../main.c", line 33: warning #551-D: variable "tscl" is used before its value is set 2 errors detected in the compilation of "../main.c". >> Compilation failure gmake: *** [main.obj] Error 1 gmake: Target `all' not remade because of errors. **** Build Finished ****
最新发布
06-06
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值