基于EBAZ4205矿板的图像处理:10gamma变换

基于EBAZ4205矿板的图像处理:10gamma变换

项目全部文件

会上传项目全部文件,如果没传,可以私信催我一下,最近太忙了

先看效果

在这里插入图片描述

请添加图片描述
我的项目中的gamma的变换系数为2.2,是会让图像整体变暗的,看右图说明我的gamma变换模块生效了。

算法

gamma映射是一种简单的、常见的图像处理方法,它能够拓展图像的低亮度区域的灰度级数,让图像的低亮度区域呈现更多的细节,但同时也会让图像的整体亮度变暗,有利有弊。
算法的公式为: y = A*x^g
其中,x为像素点的像素灰度值输入,y为像素点的像素灰度值变换结果,A为归一化系数,g为gamma变换系数。
下图是不同系数的gamma变换曲线。
在这里插入图片描述

算法的FPGA部署

首先,gamma变换是个指数函数。用FPGA来运算指数函数相当耗时,所以为了提升速度,我们采用查表法,既将某个gamma变换系数下的0~255灰度等级的所有对应变换结果算出来,然后在需要映射时,直接查表即可。

BD

在这里插入图片描述

项目代码

图像处理模块

module video_processor((* X_INTERFACE_IGNORE = "true" *) input         frame_clk,    //cmos 像素时钟(* X_INTERFACE_IGNORE = "true" *) input         frame_rst_n,  //预处理图像(* X_INTERFACE_IGNORE = "true" *) input         pre_vsync, //预处理图像场同步信号(* X_INTERFACE_IGNORE = "true" *) input [23:0]  pre_data,  //预处理图像数据(* X_INTERFACE_IGNORE = "true" *) input         pre_href,  //预处理图像数据有效信号(* X_INTERFACE_IGNORE = "true" *) input         pre_frame_ce, //预处理图像时钟使能信号//处理后图像(* X_INTERFACE_IGNORE = "true" *) output        pos_vsync, //处理后图像场同步信号(* X_INTERFACE_IGNORE = "true" *) output [23:0] pos_data,  //处理后图像数据(* X_INTERFACE_IGNORE = "true" *) output        pos_href, //处理后图像数据有效信号(* X_INTERFACE_IGNORE = "true" *) output        pos_frame_ce //处理后图像时钟使能信号  
);wire [7:0] gray_data ;
wire [7:0] post_gray_data ;rgb2gray  u_rgb2gray(.cmos_frame_clk     (frame_clk      ),.cmos_rstn          (frame_rst_n    ),//同步复位.cmos_frame_vsync   (pre_vsync      ),.cmos_frame_data    (pre_data       ),.cmos_frame_href    (pre_href       ),.cmos_frame_ce      (pre_frame_ce   ),.dataout_frame_vsync(pos_vsync     ),.dataout_frame_data (gray_data      ),.dataout_frame_href (pos_href      ),.dataout_frame_ce   (pos_frame_ce  )
);assign pos_data = {3{post_gray_data}};
Curve_Gamma_2P2 u_Curve_Gamma_2P2(.Pre_Data (gray_data),.Post_Data(post_gray_data)
);
endmodule 

色彩转换模块

`timescale 1ns / 1ps
module rgb2gray((* X_INTERFACE_IGNORE = "true" *)  input           cmos_frame_vsync,
(* X_INTERFACE_IGNORE = "true" *)  input [23:0]    cmos_frame_data,
(* X_INTERFACE_IGNORE = "true" *)  input           cmos_frame_href,(* X_INTERFACE_IGNORE = "true" *)  input           cmos_frame_clk,
(* X_INTERFACE_IGNORE = "true" *)  input           cmos_rstn,//同步复位
(* X_INTERFACE_IGNORE = "true" *)  input           cmos_frame_ce,(* X_INTERFACE_IGNORE = "true" *)  output          dataout_frame_vsync,
(* X_INTERFACE_IGNORE = "true" *)  output [7:0]    dataout_frame_data,
// (* X_INTERFACE_IGNORE = "true" *)  output [23:0]    dataout_frame_data,
(* X_INTERFACE_IGNORE = "true" *)  output          dataout_frame_href,
(* X_INTERFACE_IGNORE = "true" *)  output          dataout_frame_ce);// Y = 0.299R +0.587G + 0.114B// Y = (77 *R + 150*G + 29 *B)>>8reg [15:0] r_gray1;reg [15:0] g_gray1;reg [15:0] b_gray1;reg [15:0] y1;reg [7:0] y2;reg [2:0] dataout_frame_vsync_r;reg [2:0] dataout_frame_href_r;reg [2:0] dataout_frame_ce_r;always@(posedge cmos_frame_clk)beginif(!cmos_rstn)beginr_gray1 <= 8'h00;g_gray1 <= 8'h00;b_gray1 <= 8'h00;endelse beginr_gray1 <= cmos_frame_data[23:16]  * 8'd77 ;g_gray1 <= cmos_frame_data[15:8]   * 8'd150;b_gray1 <= cmos_frame_data[7:0]    * 8'd29 ;endendalways@(posedge cmos_frame_clk)beginif(!cmos_rstn)beginy1 <= 16'h0000;endelse beginy1 <= r_gray1 + g_gray1 + b_gray1;endendalways@(posedge cmos_frame_clk)beginif(!cmos_rstn)beginy2 <= 8'h0000;endelse beginy2 <= y1[15:8];endendalways@(posedge cmos_frame_clk)beginif(!cmos_rstn)begindataout_frame_ce_r      <= 3'b000;dataout_frame_vsync_r   <= 3'b000;dataout_frame_href_r    <= 3'b000;endelse begindataout_frame_ce_r      <= {dataout_frame_ce_r[1:0]     ,cmos_frame_ce};dataout_frame_vsync_r   <= {dataout_frame_vsync_r[1:0]  ,cmos_frame_vsync};dataout_frame_href_r    <= {dataout_frame_href_r[1:0]   ,cmos_frame_href};endend// assign dataout_frame_data = {y2,y2,y2};assign dataout_frame_data = y2;assign dataout_frame_ce = dataout_frame_ce_r[2];assign dataout_frame_vsync = dataout_frame_vsync_r[2];assign dataout_frame_href = dataout_frame_href_r[2];endmodule

gamma映射模块

//Curve of Gamma = 2.2
module Curve_Gamma_2P2
(input		[7:0]	Pre_Data,output	reg	[7:0]	Post_Data
);always@(*)
begincase(Pre_Data)8'h00 : Post_Data = 8'h00; 8'h01 : Post_Data = 8'h00; 8'h02 : Post_Data = 8'h00; 8'h03 : Post_Data = 8'h00; 8'h04 : Post_Data = 8'h00; 8'h05 : Post_Data = 8'h00; 8'h06 : Post_Data = 8'h00; 8'h07 : Post_Data = 8'h00; 8'h08 : Post_Data = 8'h00; 8'h09 : Post_Data = 8'h00; 8'h0A : Post_Data = 8'h00; 8'h0B : Post_Data = 8'h00; 8'h0C : Post_Data = 8'h00; 8'h0D : Post_Data = 8'h00; 8'h0E : Post_Data = 8'h00; 8'h0F : Post_Data = 8'h01; 8'h10 : Post_Data = 8'h01; 8'h11 : Post_Data = 8'h01; 8'h12 : Post_Data = 8'h01; 8'h13 : Post_Data = 8'h01; 8'h14 : Post_Data = 8'h01; 8'h15 : Post_Data = 8'h01; 8'h16 : Post_Data = 8'h01; 8'h17 : Post_Data = 8'h01; 8'h18 : Post_Data = 8'h01; 8'h19 : Post_Data = 8'h02; 8'h1A : Post_Data = 8'h02; 8'h1B : Post_Data = 8'h02; 8'h1C : Post_Data = 8'h02; 8'h1D : Post_Data = 8'h02; 8'h1E : Post_Data = 8'h02; 8'h1F : Post_Data = 8'h02; 8'h20 : Post_Data = 8'h03; 8'h21 : Post_Data = 8'h03; 8'h22 : Post_Data = 8'h03; 8'h23 : Post_Data = 8'h03; 8'h24 : Post_Data = 8'h03; 8'h25 : Post_Data = 8'h04; 8'h26 : Post_Data = 8'h04; 8'h27 : Post_Data = 8'h04; 8'h28 : Post_Data = 8'h04; 8'h29 : Post_Data = 8'h05; 8'h2A : Post_Data = 8'h05; 8'h2B : Post_Data = 8'h05; 8'h2C : Post_Data = 8'h05; 8'h2D : Post_Data = 8'h06; 8'h2E : Post_Data = 8'h06; 8'h2F : Post_Data = 8'h06; 8'h30 : Post_Data = 8'h06; 8'h31 : Post_Data = 8'h07; 8'h32 : Post_Data = 8'h07; 8'h33 : Post_Data = 8'h07; 8'h34 : Post_Data = 8'h08; 8'h35 : Post_Data = 8'h08; 8'h36 : Post_Data = 8'h08; 8'h37 : Post_Data = 8'h09; 8'h38 : Post_Data = 8'h09; 8'h39 : Post_Data = 8'h09; 8'h3A : Post_Data = 8'h0A; 8'h3B : Post_Data = 8'h0A; 8'h3C : Post_Data = 8'h0B; 8'h3D : Post_Data = 8'h0B; 8'h3E : Post_Data = 8'h0B; 8'h3F : Post_Data = 8'h0C; 8'h40 : Post_Data = 8'h0C; 8'h41 : Post_Data = 8'h0D; 8'h42 : Post_Data = 8'h0D; 8'h43 : Post_Data = 8'h0D; 8'h44 : Post_Data = 8'h0E; 8'h45 : Post_Data = 8'h0E; 8'h46 : Post_Data = 8'h0F; 8'h47 : Post_Data = 8'h0F; 8'h48 : Post_Data = 8'h10; 8'h49 : Post_Data = 8'h10; 8'h4A : Post_Data = 8'h11; 8'h4B : Post_Data = 8'h11; 8'h4C : Post_Data = 8'h12; 8'h4D : Post_Data = 8'h12; 8'h4E : Post_Data = 8'h13; 8'h4F : Post_Data = 8'h13; 8'h50 : Post_Data = 8'h14; 8'h51 : Post_Data = 8'h14; 8'h52 : Post_Data = 8'h15; 8'h53 : Post_Data = 8'h16; 8'h54 : Post_Data = 8'h16; 8'h55 : Post_Data = 8'h17; 8'h56 : Post_Data = 8'h17; 8'h57 : Post_Data = 8'h18; 8'h58 : Post_Data = 8'h19; 8'h59 : Post_Data = 8'h19; 8'h5A : Post_Data = 8'h1A; 8'h5B : Post_Data = 8'h1A; 8'h5C : Post_Data = 8'h1B; 8'h5D : Post_Data = 8'h1C; 8'h5E : Post_Data = 8'h1C; 8'h5F : Post_Data = 8'h1D; 8'h60 : Post_Data = 8'h1E; 8'h61 : Post_Data = 8'h1E; 8'h62 : Post_Data = 8'h1F; 8'h63 : Post_Data = 8'h20; 8'h64 : Post_Data = 8'h21; 8'h65 : Post_Data = 8'h21; 8'h66 : Post_Data = 8'h22; 8'h67 : Post_Data = 8'h23; 8'h68 : Post_Data = 8'h23; 8'h69 : Post_Data = 8'h24; 8'h6A : Post_Data = 8'h25; 8'h6B : Post_Data = 8'h26; 8'h6C : Post_Data = 8'h27; 8'h6D : Post_Data = 8'h27; 8'h6E : Post_Data = 8'h28; 8'h6F : Post_Data = 8'h29; 8'h70 : Post_Data = 8'h2A; 8'h71 : Post_Data = 8'h2B; 8'h72 : Post_Data = 8'h2B; 8'h73 : Post_Data = 8'h2C; 8'h74 : Post_Data = 8'h2D; 8'h75 : Post_Data = 8'h2E; 8'h76 : Post_Data = 8'h2F; 8'h77 : Post_Data = 8'h30; 8'h78 : Post_Data = 8'h31; 8'h79 : Post_Data = 8'h31; 8'h7A : Post_Data = 8'h32; 8'h7B : Post_Data = 8'h33; 8'h7C : Post_Data = 8'h34; 8'h7D : Post_Data = 8'h35; 8'h7E : Post_Data = 8'h36; 8'h7F : Post_Data = 8'h37; 8'h80 : Post_Data = 8'h38; 8'h81 : Post_Data = 8'h39; 8'h82 : Post_Data = 8'h3A; 8'h83 : Post_Data = 8'h3B; 8'h84 : Post_Data = 8'h3C; 8'h85 : Post_Data = 8'h3D; 8'h86 : Post_Data = 8'h3E; 8'h87 : Post_Data = 8'h3F; 8'h88 : Post_Data = 8'h40; 8'h89 : Post_Data = 8'h41; 8'h8A : Post_Data = 8'h42; 8'h8B : Post_Data = 8'h43; 8'h8C : Post_Data = 8'h44; 8'h8D : Post_Data = 8'h45; 8'h8E : Post_Data = 8'h46; 8'h8F : Post_Data = 8'h47; 8'h90 : Post_Data = 8'h49; 8'h91 : Post_Data = 8'h4A; 8'h92 : Post_Data = 8'h4B; 8'h93 : Post_Data = 8'h4C; 8'h94 : Post_Data = 8'h4D; 8'h95 : Post_Data = 8'h4E; 8'h96 : Post_Data = 8'h4F; 8'h97 : Post_Data = 8'h51; 8'h98 : Post_Data = 8'h52; 8'h99 : Post_Data = 8'h53; 8'h9A : Post_Data = 8'h54; 8'h9B : Post_Data = 8'h55; 8'h9C : Post_Data = 8'h57; 8'h9D : Post_Data = 8'h58; 8'h9E : Post_Data = 8'h59; 8'h9F : Post_Data = 8'h5A; 8'hA0 : Post_Data = 8'h5B; 8'hA1 : Post_Data = 8'h5D; 8'hA2 : Post_Data = 8'h5E; 8'hA3 : Post_Data = 8'h5F; 8'hA4 : Post_Data = 8'h61; 8'hA5 : Post_Data = 8'h62; 8'hA6 : Post_Data = 8'h63; 8'hA7 : Post_Data = 8'h64; 8'hA8 : Post_Data = 8'h66; 8'hA9 : Post_Data = 8'h67; 8'hAA : Post_Data = 8'h69; 8'hAB : Post_Data = 8'h6A; 8'hAC : Post_Data = 8'h6B; 8'hAD : Post_Data = 8'h6D; 8'hAE : Post_Data = 8'h6E; 8'hAF : Post_Data = 8'h6F; 8'hB0 : Post_Data = 8'h71; 8'hB1 : Post_Data = 8'h72; 8'hB2 : Post_Data = 8'h74; 8'hB3 : Post_Data = 8'h75; 8'hB4 : Post_Data = 8'h77; 8'hB5 : Post_Data = 8'h78; 8'hB6 : Post_Data = 8'h79; 8'hB7 : Post_Data = 8'h7B; 8'hB8 : Post_Data = 8'h7C; 8'hB9 : Post_Data = 8'h7E; 8'hBA : Post_Data = 8'h7F; 8'hBB : Post_Data = 8'h81; 8'hBC : Post_Data = 8'h82; 8'hBD : Post_Data = 8'h84; 8'hBE : Post_Data = 8'h85; 8'hBF : Post_Data = 8'h87; 8'hC0 : Post_Data = 8'h89; 8'hC1 : Post_Data = 8'h8A; 8'hC2 : Post_Data = 8'h8C; 8'hC3 : Post_Data = 8'h8D; 8'hC4 : Post_Data = 8'h8F; 8'hC5 : Post_Data = 8'h91; 8'hC6 : Post_Data = 8'h92; 8'hC7 : Post_Data = 8'h94; 8'hC8 : Post_Data = 8'h95; 8'hC9 : Post_Data = 8'h97; 8'hCA : Post_Data = 8'h99; 8'hCB : Post_Data = 8'h9A; 8'hCC : Post_Data = 8'h9C; 8'hCD : Post_Data = 8'h9E; 8'hCE : Post_Data = 8'h9F; 8'hCF : Post_Data = 8'hA1; 8'hD0 : Post_Data = 8'hA3; 8'hD1 : Post_Data = 8'hA5; 8'hD2 : Post_Data = 8'hA6; 8'hD3 : Post_Data = 8'hA8; 8'hD4 : Post_Data = 8'hAA; 8'hD5 : Post_Data = 8'hAC; 8'hD6 : Post_Data = 8'hAD; 8'hD7 : Post_Data = 8'hAF; 8'hD8 : Post_Data = 8'hB1; 8'hD9 : Post_Data = 8'hB3; 8'hDA : Post_Data = 8'hB5; 8'hDB : Post_Data = 8'hB6; 8'hDC : Post_Data = 8'hB8; 8'hDD : Post_Data = 8'hBA; 8'hDE : Post_Data = 8'hBC; 8'hDF : Post_Data = 8'hBE; 8'hE0 : Post_Data = 8'hC0; 8'hE1 : Post_Data = 8'hC2; 8'hE2 : Post_Data = 8'hC4; 8'hE3 : Post_Data = 8'hC5; 8'hE4 : Post_Data = 8'hC7; 8'hE5 : Post_Data = 8'hC9; 8'hE6 : Post_Data = 8'hCB; 8'hE7 : Post_Data = 8'hCD; 8'hE8 : Post_Data = 8'hCF; 8'hE9 : Post_Data = 8'hD1; 8'hEA : Post_Data = 8'hD3; 8'hEB : Post_Data = 8'hD5; 8'hEC : Post_Data = 8'hD7; 8'hED : Post_Data = 8'hD9; 8'hEE : Post_Data = 8'hDB; 8'hEF : Post_Data = 8'hDD; 8'hF0 : Post_Data = 8'hDF; 8'hF1 : Post_Data = 8'hE1; 8'hF2 : Post_Data = 8'hE3; 8'hF3 : Post_Data = 8'hE5; 8'hF4 : Post_Data = 8'hE7; 8'hF5 : Post_Data = 8'hEA; 8'hF6 : Post_Data = 8'hEC; 8'hF7 : Post_Data = 8'hEE; 8'hF8 : Post_Data = 8'hF0; 8'hF9 : Post_Data = 8'hF2; 8'hFA : Post_Data = 8'hF4; 8'hFB : Post_Data = 8'hF6; 8'hFC : Post_Data = 8'hF8; 8'hFD : Post_Data = 8'hFB; 8'hFE : Post_Data = 8'hFD; 8'hFF : Post_Data = 8'hFF; endcase
endendmodule

vitis代码

//作者:抢公主的大魔王
//功能:gamma映射
//日期:24.5.27
//版本:1v0
//联系方式:2376635586@qq.com
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xil_types.h"
#include "xil_cache.h"
#include "xparameters.h"
#include "xgpiops.h"
#include "xscugic.h"
#include "xil_exception.h"
#include "xplatform_info.h"
#include "xaxivdma.h"
#include "xaxivdma_i.h"
#include "display_ctrl_hdmi/display_ctrl.h"
#include "vdma_api/vdma_api.h"
#include "emio_sccb_cfg/emio_sccb_cfg.h"
#include "ov5640/ov5640_init.h"
#include "sleep.h"//宏定义
#define DYNCLK_BASEADDR  	XPAR_AXI_DYNCLK_0_BASEADDR  //动态时钟基地址
#define VDMA_ID          	XPAR_AXIVDMA_0_DEVICE_ID    //VDMA器件ID
#define DISP_VTC_ID      	XPAR_VTC_0_DEVICE_ID        //VTC器件ID
//#define THRESHOLD_BASEADDR 	XPAR_AXICTRLTHRESHOLD_0_S00_AXI_BASEADDR#define EMIO_SCL_NUM 54
#define EMIO_SDA_NUM 55
#define KEY1 56 //T19
#define KEY2 57 //P19
#define KEY3 58 //U20
#define KEY4 59 //U19
#define KEY5 60 //V20
#define LED1 61 //H18
#define LED2 62 //K17
#define LED3 63 //E19#define GPIO_DEVICE_ID  	XPAR_XGPIOPS_0_DEVICE_ID
XGpioPs Gpio;
#define GPIO_BANK	XGPIOPS_BANK0  /* Bank 0 of the GPIO Device */
#define INTC_DEVICE_ID		XPAR_SCUGIC_SINGLE_DEVICE_ID
#define GPIO_INTERRUPT_ID	XPAR_XGPIOPS_0_INTR//全局变量
//frame buffer的起始地址
unsigned int const frame_buffer_addr = (XPAR_PS7_DDR_0_S_AXI_BASEADDR+ 0x1000000);
//u8 binary_threshold = 128;
XAxiVdma     vdma;
DisplayCtrl  dispCtrl;
VideoMode    vd_mode;static XScuGic Intc; /* The Instance of the Interrupt Controller Driver */static void IntrHandler(void *CallBackRef, u32 Bank, u32 Status)
{XGpioPs *Gpio_cb = (XGpioPs *)CallBackRef;if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY1)){//binary_threshold++;//Xil_Out32(THRESHOLD_BASEADDR, binary_threshold);//xil_printf("The threshold has been changed\n\rThe threshold now is %d\n\r",binary_threshold);XGpioPs_IntrClearPin(Gpio_cb, KEY1);}else if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY4)){//binary_threshold--;//Xil_Out32(THRESHOLD_BASEADDR, binary_threshold);//xil_printf("The threshold has been changed\n\rThe threshold now is %d\n\r",binary_threshold);XGpioPs_IntrClearPin(Gpio_cb, KEY4);}else if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY2)){//binary_threshold = binary_threshold+10;//Xil_Out32(THRESHOLD_BASEADDR, binary_threshold);//xil_printf("The threshold has been changed\n\rThe threshold now is %d\n\r",binary_threshold);XGpioPs_IntrClearPin(Gpio_cb, KEY2);}else if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY5)){//binary_threshold = binary_threshold-10;//Xil_Out32(THRESHOLD_BASEADDR, binary_threshold);//xil_printf("The threshold has been changed\n\rThe threshold now is %d\n\r",binary_threshold);XGpioPs_IntrClearPin(Gpio_cb, KEY5);}else if (XGpioPs_IntrGetStatusPin(Gpio_cb, KEY3)){//binary_threshold = 128;//Xil_Out32(THRESHOLD_BASEADDR, binary_threshold);//xil_printf("The threshold has been reset\n\rThe threshold now is %d\n\r",binary_threshold);XGpioPs_IntrClearPin(Gpio_cb, KEY3);}XGpioPs_WritePin(&Gpio, LED1, !XGpioPs_ReadPin(&Gpio, LED1));
}void SetupInterruptSystem(XScuGic *GicInstancePtr, XGpioPs *Gpio,u16 GpioIntrId){XScuGic_Config *IntcConfig;Xil_ExceptionInit();IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);XScuGic_CfgInitialize(GicInstancePtr, IntcConfig,IntcConfig->CpuBaseAddress);Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,(Xil_ExceptionHandler)XScuGic_InterruptHandler,GicInstancePtr);XScuGic_Connect(GicInstancePtr, GpioIntrId,(Xil_ExceptionHandler)IntrHandler,(void *)Gpio);XScuGic_Enable(GicInstancePtr, GpioIntrId);XGpioPs_SetIntrTypePin(Gpio, KEY1,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);XGpioPs_SetIntrTypePin(Gpio, KEY2,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);XGpioPs_SetIntrTypePin(Gpio, KEY3,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);XGpioPs_SetIntrTypePin(Gpio, KEY4,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);XGpioPs_SetIntrTypePin(Gpio, KEY5,  XGPIOPS_IRQ_TYPE_EDGE_FALLING);XGpioPs_IntrEnablePin(Gpio, KEY1);XGpioPs_IntrEnablePin(Gpio, KEY2);XGpioPs_IntrEnablePin(Gpio, KEY3);XGpioPs_IntrEnablePin(Gpio, KEY4);XGpioPs_IntrEnablePin(Gpio, KEY5);Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
}void Gpio_Init(void){XGpioPs_Config *ConfigPtr;ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);XGpioPs_CfgInitialize(&Gpio, ConfigPtr,ConfigPtr->BaseAddr);XGpioPs_SetDirectionPin(&Gpio, LED1, 1);XGpioPs_SetOutputEnablePin(&Gpio, LED1, 1);XGpioPs_WritePin(&Gpio, LED1, 0);XGpioPs_SetDirectionPin(&Gpio, LED2, 1);XGpioPs_SetOutputEnablePin(&Gpio, LED2, 1);XGpioPs_WritePin(&Gpio, LED2, 0);XGpioPs_SetDirectionPin(&Gpio, LED3, 1);XGpioPs_SetOutputEnablePin(&Gpio, LED3, 1);XGpioPs_WritePin(&Gpio, LED3, 0);XGpioPs_SetDirectionPin(&Gpio, KEY1, 0);XGpioPs_SetDirectionPin(&Gpio, KEY2, 0);XGpioPs_SetDirectionPin(&Gpio, KEY3, 0);XGpioPs_SetDirectionPin(&Gpio, KEY4, 0);XGpioPs_SetDirectionPin(&Gpio, KEY5, 0);SetupInterruptSystem(&Intc, &Gpio, GPIO_INTERRUPT_ID);}int main(void)
{u32 status;u16 cmos_h_pixel;                    //ov5640 DVP 输出水平像素点数u16 cmos_v_pixel;                    //ov5640 DVP 输出垂直像素点数u16 total_h_pixel;                   //ov5640 水平总像素大小u16 total_v_pixel;                   //ov5640 垂直总像素大小cmos_h_pixel = 1280;cmos_v_pixel = 720;total_h_pixel = 2570;total_v_pixel = 980;emio_init();status = ov5640_init( cmos_h_pixel,  //初始化ov5640cmos_v_pixel,total_h_pixel,total_v_pixel);//设置OV5640输出分辨率为1280*720  PCLK = 72Mhzif(status == 0)xil_printf("OV5640 detected successful!\r\n");elsexil_printf("OV5640 detected failed!\r\n");vd_mode = VMODE_1280x720;//配置VDMArun_vdma_frame_buffer(&vdma, VDMA_ID, vd_mode.width, vd_mode.height,frame_buffer_addr,0,0,BOTH);//初始化Display controllerDisplayInitialize(&dispCtrl, DISP_VTC_ID, DYNCLK_BASEADDR);//设置VideoModeDisplaySetMode(&dispCtrl, &vd_mode);DisplayStart(&dispCtrl);Gpio_Init();while(1){XGpioPs_WritePin(&Gpio, LED3, !XGpioPs_ReadPin(&Gpio, LED3));sleep(1);}return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/21624.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

CPVT(ICLR 2023)论文解读

paper&#xff1a;Conditional Positional Encodings for Vision Transformers official implementation&#xff1a;GitHub - Meituan-AutoML/CPVT 存在的问题 位置编码的局限性&#xff1a;传统Transformer中的绝对位置编码&#xff08;无论是可学习的还是固定的&#xff…

【c++进阶(二)】STL之string类的模拟实现

&#x1f493;博主CSDN主页:Am心若依旧&#x1f493; ⏩专栏分类c从入门到精通⏪ &#x1f69a;代码仓库:青酒余成&#x1f69a; &#x1f339;关注我&#x1faf5;带你学习更多c   &#x1f51d;&#x1f51d; 1.前言 本章重点 本章主要介绍一些关键接口的模拟实现&#xff…

0603《哎选》已经稳定运行2年

0603《哎选》已经稳定运行2年 0603《哎选》已经稳定运行2年 介绍 2022年6月3日经过一年的努力&#xff0c;优雅草蜻蜓G系统原生版诞生&#xff0c;本产品应用于《哎选》&#xff0c;经过2年的运营不断的更新迭代&#xff0c;目前产品已经有了一定的用户量&#xff0c;本产品…

Spark 3.5.1 升级 Java 17 异常 cannot access class sun.nio.ch.DirectBuffer

异常说明 使用Spark 3.5.1 升级到Java17的时候会有一个异常&#xff0c;异常如下 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.htm…

离轴磁编案例分享 - 机器人关机模组

客户产品 六轴协作机器人产品 关机模组 关机模组内部结构 项目介绍 客户需求: 需要离轴&#xff0c;优点&#xff1a;可以中空走线&#xff0c;方便线缆从机器人中间穿过去&#xff0c;可以更好得保护好线缆&#xff0c;不需要把线漏在外面&#xff0c;影响使用和产品寿命。目…

最适合上班族和宝妈的兼职副业,一天500多,小众副业项目

近年来&#xff0c;地方特色小吃逐渐受到人们的热烈追捧&#xff0c;尤其是在直播的助力下&#xff0c;许多地方的特色小吃得以走进大众视野&#xff0c;吸引了大量流量和人气。因此&#xff0c;有很大一部分商家和创业者看准了这一商机&#xff0c;纷纷投身于地方特色小吃的制…

怎么把多种内容做成二维码?扫码展现多种内容的制作方法

现在很多的场景下都有不同类型的二维码&#xff0c;用来承载内容为用户提供内容展示&#xff0c;比如图片、视频、文字、文件、地图等等内容&#xff0c;都可以组合起来通过扫码的方式在手机上展示。那么如何制作组合内容的二维码相信有很多的小伙伴都非常的感兴趣。 其实二维…

众汇:外汇狙击指标如何使用?

对于投资者来说&#xff0c;我们各位交易的目的是什么?WeTrade众汇认为那就是盈利。所以来说有一个指标对各位投资者来说那是相当有帮助的。这是因为对于交易者而言&#xff0c;利用这些指标可以快速识别盈利的买卖时机。当我们选择一个指标之后&#xff0c;深入了解其适用范围…

「布道师系列文章」众安保险王凯解析 Kafka 网络通信

作者&#xff5c;众安保险基础平台 Java 开发专家王凯 引言 今天给大家带来的是 Kafka 网路通信主要流程的解析&#xff08;基于 Apache Kafka 3.7[2]&#xff09;。同时引申分析了业界当前较火的AutoMQ基于Kafka在网络通信层面的优化和提升。 01 如何构建一个基本的请求…

学习笔记(一)——Langchain基本操作与函数

学习笔记(一)——Langchain基本操作与函数 目录 学习笔记(一)——Langchain基本操作与函数基本初始化配置LangsmithLanguage Models 基础指令传递信息OutputParsers 输出解析器chain 链Prompt Templates 提示模板Message History 消息历史记录Managing Conversation History 管…

XL7005A SOP-8 0.4A1.25-20V 150KHz降压直流转换器芯片

XL7005A作为一款高性能的降压型电源管理芯片&#xff0c;在智能家居中有着广泛的应用。以下是一些具体的案例&#xff1a; 1. 智能灯具&#xff1a;XL7005A可用于控制LED灯的电源&#xff0c;提供稳定高效的电源支持&#xff0c;确保灯具亮度稳定且无频闪&#xff0c;提高用户体…

springboot从2.7.2 升级到 3.3.0

文章目录 概要准备报错调整小结后记 概要 时代在进步&#xff0c;springboot已经来到了3.3.0 , 于是我们也打算升级下sbvadmin到3.3&#xff0c; jdk使用21的版本&#xff0c;下面是升级过程中碰到的一些问题&#xff0c;问题不大。 2.7.2 -> 3.3.0 准备 下载jdk21&#…

windows的软件修改图标

要修改一个可执行文件&#xff08;.exe&#xff09;的图标&#xff0c;你可以使用 Resource Hacker 这样的工具。Resource Hacker 是一个免费的资源编辑器&#xff0c;可以用于修改和编辑 Windows 可执行文件中的资源。 以下是一个简单的步骤来修改一个 .exe 文件的图标&#x…

shell脚本 字符串拼接变量赋值失效

问题现象&#xff1a; 代码如下&#xff1a; 执行结果&#xff1a; 可以看到data_dir属性是有值的&#xff0c;但是做字符串拼接变量赋值失效了很奇怪 怀疑赋值哪里写错了 问题分析&#xff1a; 1. 还是觉得赋值没有问题&#xff0c;手动显式赋值再执行下 执行结果&#…

职场如同“染缸”,老板只是给你个平台,染的好坏,全凭运气!

无论哪个单位&#xff0c;在职场大染缸里总有那么一拨同事是你喜欢的&#xff0c;也有那么一拨同事是不痛不痒的&#xff0c;还有那么一拨同事却是你怎么看都觉得不顺眼的。“不顺眼”的定义很宽泛&#xff0c;可能是他曾经的一些言论触及了你的道德底线&#xff0c;可能是他的…

C++数据结构之:堆Heap

摘要&#xff1a; it人员无论是使用哪种高级语言开发东东&#xff0c;想要更高效有层次的开发程序的话都躲不开三件套&#xff1a;数据结构&#xff0c;算法和设计模式。数据结构是相互之间存在一种或多种特定关系的数据元素的集合&#xff0c;即带“结构”的数据元素的集合&am…

【Qt】win10,QTableWidget表头下无分隔线的问题

1. 现象 2. 原因 win10系统的UI样式默认是这样的。 3. 解决 - 方法1 //横向表头ui->table->horizontalHeader()->setStyleSheet("QHeaderView::section{""border-top:0px solid #E5E5E5;""border-left:0px solid #E5E5E5;""bord…

Matlab|【重磅】配电网故障重构/孤岛划分

目录 1 主要内容 1.1 背景 1.2 流程图 2 部分代码 3 程序结果 4 下载链接 1 主要内容 程序主要复现《基于GA_BFGS算法的配电网故障恢复性重构研究_郑海广》&#xff0c;采用matlab编程软件实现&#xff0c;依据网络结构和DG供电方式对配电网进行孤岛划分&#xff0c;将含…

【算法训练记录——Day24】

Day24——回溯算法Ⅰ 77.组合 今日内容&#xff1a; ● 理论基础 ● 77. 组合 理论&#xff1a;代码随想录 77.组合 思路&#xff1a;k层for循环&#xff0c;不会 回溯&#xff0c;将组合问题抽象成n叉树&#xff0c;for循环控制宽度&#xff0c;递归的深度控制二叉树的深度 …

CSS学习笔记之高级教程(五)

23、CSS 媒体查询 - 实例 /* 如果屏幕尺寸超过 600 像素&#xff0c;把 <div> 的字体大小设置为 80 像素 */ media screen and (min-width: 600px) {div.example {font-size: 80px;} }/* 如果屏幕大小为 600px 或更小&#xff0c;把 <div> 的字体大小设置为 30px …