fix some bugs
This commit is contained in:
parent
d345fed4e7
commit
1ad504cb9f
|
@ -22,7 +22,7 @@ module crop #(
|
|||
localparam SEND_DATA = 2;
|
||||
|
||||
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;
|
||||
|
||||
// 状态切换
|
||||
|
|
|
@ -150,8 +150,15 @@ module demosaic2 #(
|
|||
cnt_data <= 0;
|
||||
pos_x <= 0;
|
||||
pos_y <= pos_y + 1;
|
||||
if (pos_y >= IM_HEIGHT - 2 - 1)
|
||||
if (pos_y >= IM_HEIGHT - 2 - 1) begin
|
||||
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
|
||||
else begin
|
||||
cnt_data <= 2;
|
||||
|
|
6
isp.v
6
isp.v
|
@ -21,6 +21,8 @@ module isp #(
|
|||
output wire out_en,
|
||||
output reg [3 * COLOR_DEPTH - 1:0] data_out
|
||||
);
|
||||
localparam BAYER_WIDTH = IN_WIDTH - 2;
|
||||
localparam BAYER_HEIGHT = IN_HEIGHT - 2;
|
||||
// 三通道合成RGB图像
|
||||
wire rgb_en;
|
||||
wire [15:0] im_red, im_green, im_blue;
|
||||
|
@ -66,8 +68,8 @@ module isp #(
|
|||
);
|
||||
|
||||
crop #(
|
||||
.IN_WIDTH(IN_WIDTH),
|
||||
.IN_HEIGHT(IN_HEIGHT),
|
||||
.IN_WIDTH(BAYER_WIDTH),
|
||||
.IN_HEIGHT(BAYER_HEIGHT),
|
||||
.OUT_WIDTH(OUT_WIDTH),
|
||||
.OUT_HEIGHT(OUT_HEIGHT),
|
||||
.COLOR_DEPTH(COLOR_DEPTH)
|
||||
|
|
|
@ -119,7 +119,7 @@ int sc_main(int argc, char* argv[]) {
|
|||
ifstream in_image;
|
||||
ofstream out_image;
|
||||
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()) {
|
||||
cout << "Open image fail" << endl;
|
||||
exit(0);
|
||||
|
@ -128,13 +128,11 @@ int sc_main(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
// Read image
|
||||
// uint8_t buf[IN_SIZE * 2] = {0};
|
||||
auto buf = make_unique<uint8_t[]>(2 * IN_SIZE);
|
||||
// vector<vector<uint8_t>> buf(IN_HEIGHT, vector<uint8_t>(IN_WIDTH, 0));
|
||||
in_image.read((char*)buf.get(), IN_SIZE * 2);
|
||||
in_image.close();
|
||||
// Reshape data
|
||||
// uint16_t image[IN_HEIGHT][IN_WIDTH] = {0};
|
||||
auto image = make_unique<uint16_t[]>(IN_SIZE);
|
||||
uint32_t i = 0;
|
||||
for (int y = 0; y < IN_HEIGHT; y++) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import imageio
|
||||
import numpy as np
|
||||
|
||||
im_width = 512
|
||||
im_height = 256
|
||||
im_width = 640
|
||||
im_height = 480
|
||||
|
||||
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))
|
||||
imageio.imsave("./out.png", image)
|
||||
|
|
Loading…
Reference in New Issue