fix some bugs

This commit is contained in:
SikongJueluo 2024-05-17 16:47:28 +08:00
parent d345fed4e7
commit 1ad504cb9f
No known key found for this signature in database
GPG Key ID: D2D3D29A993716EA
5 changed files with 17 additions and 10 deletions

View File

@ -22,7 +22,7 @@ module crop #(
localparam SEND_DATA = 2; localparam SEND_DATA = 2;
reg [1:0] state, nextState; reg [1:0] state, nextState;
reg [11:0] cnt_x, cnt_y; reg [31:0] cnt_x, cnt_y;
reg [3 * COLOR_DEPTH - 1:0] data; reg [3 * COLOR_DEPTH - 1:0] data;
// 状态切换 // 状态切换

View File

@ -150,8 +150,15 @@ module demosaic2 #(
cnt_data <= 0; cnt_data <= 0;
pos_x <= 0; pos_x <= 0;
pos_y <= pos_y + 1; pos_y <= pos_y + 1;
if (pos_y >= IM_HEIGHT - 2 - 1) if (pos_y >= IM_HEIGHT - 2 - 1) begin
pos_y <= 0; pos_y <= 0;
case (RAW_TYPE)
0: raw_type <= 2;
1: raw_type <= 3;
2: raw_type <= 0;
3: raw_type <= 1;
endcase
end
end end
else begin else begin
cnt_data <= 2; cnt_data <= 2;

6
isp.v
View File

@ -21,6 +21,8 @@ module isp #(
output wire out_en, output wire out_en,
output reg [3 * COLOR_DEPTH - 1:0] data_out output reg [3 * COLOR_DEPTH - 1:0] data_out
); );
localparam BAYER_WIDTH = IN_WIDTH - 2;
localparam BAYER_HEIGHT = IN_HEIGHT - 2;
// 三通道合成RGB图像 // 三通道合成RGB图像
wire rgb_en; wire rgb_en;
wire [15:0] im_red, im_green, im_blue; wire [15:0] im_red, im_green, im_blue;
@ -66,8 +68,8 @@ module isp #(
); );
crop #( crop #(
.IN_WIDTH(IN_WIDTH), .IN_WIDTH(BAYER_WIDTH),
.IN_HEIGHT(IN_HEIGHT), .IN_HEIGHT(BAYER_HEIGHT),
.OUT_WIDTH(OUT_WIDTH), .OUT_WIDTH(OUT_WIDTH),
.OUT_HEIGHT(OUT_HEIGHT), .OUT_HEIGHT(OUT_HEIGHT),
.COLOR_DEPTH(COLOR_DEPTH) .COLOR_DEPTH(COLOR_DEPTH)

View File

@ -119,7 +119,7 @@ int sc_main(int argc, char* argv[]) {
ifstream in_image; ifstream in_image;
ofstream out_image; ofstream out_image;
in_image.open("./transform/test.bin", ios::in | ios::binary); in_image.open("./transform/test.bin", ios::in | ios::binary);
out_image.open("./out.bin", ios::out | ios::binary); out_image.open("./transform/out.bin", ios::out | ios::binary);
if (!in_image.is_open()) { if (!in_image.is_open()) {
cout << "Open image fail" << endl; cout << "Open image fail" << endl;
exit(0); exit(0);
@ -128,13 +128,11 @@ int sc_main(int argc, char* argv[]) {
} }
// Read image // Read image
// uint8_t buf[IN_SIZE * 2] = {0};
auto buf = make_unique<uint8_t[]>(2 * IN_SIZE); auto buf = make_unique<uint8_t[]>(2 * IN_SIZE);
// vector<vector<uint8_t>> buf(IN_HEIGHT, vector<uint8_t>(IN_WIDTH, 0)); // vector<vector<uint8_t>> buf(IN_HEIGHT, vector<uint8_t>(IN_WIDTH, 0));
in_image.read((char*)buf.get(), IN_SIZE * 2); in_image.read((char*)buf.get(), IN_SIZE * 2);
in_image.close(); in_image.close();
// Reshape data // Reshape data
// uint16_t image[IN_HEIGHT][IN_WIDTH] = {0};
auto image = make_unique<uint16_t[]>(IN_SIZE); auto image = make_unique<uint16_t[]>(IN_SIZE);
uint32_t i = 0; uint32_t i = 0;
for (int y = 0; y < IN_HEIGHT; y++) { for (int y = 0; y < IN_HEIGHT; y++) {

View File

@ -1,10 +1,10 @@
import imageio import imageio
import numpy as np import numpy as np
im_width = 512 im_width = 640
im_height = 256 im_height = 480
if __name__ == '__main__': if __name__ == '__main__':
raw = np.fromfile('./out.bin', dtype=np.int16) raw = np.fromfile('./out.bin', dtype=np.int32)
image = raw.reshape((im_height, im_width)) image = raw.reshape((im_height, im_width))
imageio.imsave("./out.png", image) imageio.imsave("./out.png", image)