我一直在嘗試使用vivado hls製作一箇中值濾波器。 有人建議我使用OpenCV imread
函數,但是當我使用它時,即使我已經包含OpenCV庫,程序也不會識別它。 如果我不使用imread
功能和使用墊子和cvLoadImage
我得到一個錯誤說以下內容:使用Mat,並識別imread函數
/../HLSAXIStreamMedian_tb.cpp:109:15: error: missing template arguments before '.' token
如果有人知道如何解決這個問題,或者給我一個替代我將不勝感激。 這是從我的測試臺代碼:
#include "HLSAXIStreamMedian.h"
int main(void) {
spix imageIn[MAX_HEIGHT][MAX_WIDTH]; // May have to malloc these if they're large
spix imageOut[MAX_HEIGHT][MAX_WIDTH];
spix imageGold[MAX_HEIGHT][MAX_WIDTH];
static uint8_t frameIn[MAX_HEIGHT * MAX_WIDTH];
FILE * imgFile = fopen("C:/img.bin","rb"); // "rb" is important - forces the image to be opened in binary mode.
fread(frameIn,1,MAX_HEIGHT*MAX_WIDTH,imgFile);
fclose(imgFile);
// Organise that data into the required image type.
spix dataIn[MAX_HEIGHT][MAX_WIDTH];
for (int y = 0; y < MAX_HEIGHT; y++) {
for (int x = 0; x < MAX_WIDTH; x++) {
spix tmp;
tmp.data = frameIn[y*MAX_WIDTH + x];
tmp.last = (x == (MAX_WIDTH-1));
tmp.user = (x == 0) && (y == 0);
dataIn[y][x] = tmp;
}
}
// spix array is now initialised.
// Mat gold(1212, 1216, CV_8UC3, Scalar(0,0, 100)); //create an image (3 channels, 8 bit image depth, 1212 high, 1216 wide, (0, 0, 100) assigned for Blue, Green and Red plane respectively.)
// imageGold = gold;
IplImage* test = cvLoadImage("C:/MedianTrial/test_image.PNG");
test = Mat.dataIn;
IplImage* gold = cvLoadImage("C:/MedianTrial/gold_output.PNG");
gold = Mat.imageGold;
//Mat test;
//test = imread("C:/MedianTrial/test_image.PNG",in_pix); // Read a sample image. "imread" does not actually exist; read or generate an image using a method of your choice.
//Mat gold;
//gold = imread("C:/MedianTrial/gold_output.PNG",imageGold); // Read a known-good image (eg. generated using Matlab's median filter).
top_median(imageIn,imageOut,1080,1920); // Call the test function.
for (int i = 0; i < 1080; i++) {
for (int j = 0; j < 1920; j++) {
if (imageOut != imageGold) {
printf("Data mismatch");// at position (%d,%d): %d != %d\n",i,j,imageOut[i][j],imageGold[i][j]);
return -1;
}
}
}
}
這是頭文件:
#define KMED 3 // KMED can be 3, 5, 7
#define KKMED 1 // KKMED == 1 for 3x3 window
#define MIN(x,y) ((x)>(y) ? (y) : (x))
#define MAX(x,y) ((x)>(y) ? (x) : (y))
#include "opencv/cxcore.h"
#include <opencv2/core/core.hpp>
#include "opencv2/highgui/highgui.hpp"
//opencv_core
//opencv_imgcodecs
//opencv_highgui
#include <iostream>
#include "hls_video.h"
#include "hls_opencv.h"
#include <ap_int.h>
#include "ap_axi_sdata.h"
#include <stdio.h>
#include <string.h>
#include <hls_stream.h>
#include <stdlib.h>
using namespace hls;
//using namespace cv;
//using namespace std;
#include <ap_axi_sdata.h>
typedef ap_axis<8,2,5,6> spix;
#ifndef GRAY11
typedef unsigned char pix_t; // 8-bit per pixel
#else
#include <ap_int.h>
typedef ap_int<11> pix_t; // 11-bit per pixel
#endif
#define MAX_HEIGHT 1080
#define MAX_WIDTH 1920
void top_median(spix in_pix[MAX_HEIGHT][MAX_WIDTH],
spix out_pix[MAX_HEIGHT][MAX_WIDTH],
short int height, short int width);
//spix in_pix[MAX_HEIGHT][MAX_WIDTH];
//spix out_pix[MAX_HEIGHT][MAX_WIDTH];
//spix out_pixtb[MAX_HEIGHT][MAX_WIDTH];
//short int height;
//short int width;
pix_t Median(pix_t window[KMED*KMED]);
enter code here
enter code here
我不知道你指的是圖書館,但使用'imread'在OpenCV中,你將需要'highgui'模塊,因此包括'highgui.h'或'highgui.hpp'。 –
告訴我們您的預處理文件中哪一行是109。你沒有標記它,我們也不知道'#include'd標題爲了自己做數學要花多長時間。 –
在頭文件中,我包含了這兩個庫(highgui.h和highgui.hpp) –