BoxFiltering の NPP の例を作成しようとしていますが、RGBA バイナリ データがある 8 ビットのグレースケール イメージを挿入しました。私のコードは次のようになります:
#include "./common/ImagesCPU.h"
#include "./common/ImagesNPP.h"
#include "./common/ImageIO.h"
#include "./common/Exceptions.h"
#include <npp.h>
void boxfilter_transform( Npp8u *oHostSrc, int width, int height ){
size_t size = width * height * 4;
// declare a device image and copy construct from the host image,
// i.e. upload host to device
npp::ImageNPP_8u_C4 oDeviceSrc(oHostSrc);
// create struct with box-filter mask size
NppiSize oMaskSize = {5, 5};
// create struct with ROI size given the current mask
NppiSize oSizeROI = {oDeviceSrc.width() - oMaskSize.width + 1, oDeviceSrc.height() - oMaskSize.height + 1};
// allocate device image of appropriatedly reduced size
npp::ImageNPP_8u_C4 oDeviceDst(oSizeROI.width, oSizeROI.height);
// set anchor point inside the mask to (0, 0)
NppiPoint oAnchor = {0, 0};
// run box filter
NppStatus eStatusNPP;
eStatusNPP = nppiFilterBox_8u_C4R(oDeviceSrc.data(), oDeviceSrc.pitch(),
oDeviceDst.data(), oDeviceDst.pitch(),
oSizeROI, oMaskSize, oAnchor);
NPP_ASSERT(NPP_NO_ERROR == eStatusNPP);
// declare a host image for the result
npp::ImageCPU_8u_C4 oHostDst(oDeviceDst.size());
// and copy the device result data into it
oDeviceDst.copyTo(oHostDst.data(), oHostDst.pitch());
return 0;
}
私はそれをコンパイルして取得しようとします:
npp_filters.cpp: In function ‘void boxfilter_transform(Npp8u*, int, int)’:
npp_filters.cpp:18:44: error: no matching function for call to ‘npp::ImageNPP<unsigned char, 4u>::ImageNPP(Npp8u*&)’
npp_filters.cpp:18:44: note: candidates are:
./common/ImagesNPP.h:52:13: note: template<class X> npp::ImageNPP::ImageNPP(const npp::ImageCPU<D, N, X>&, bool)
./common/ImagesNPP.h:45:13: note: npp::ImageNPP<D, N>::ImageNPP(const npp::ImageNPP<D, N>&) [with D = unsigned char, unsigned int N = 4u]
./common/ImagesNPP.h:45:13: note: no known conversion for argument 1 from ‘Npp8u* {aka unsigned char*}’ to ‘const npp::ImageNPP<unsigned char, 4u>&’
./common/ImagesNPP.h:40:13: note: npp::ImageNPP<D, N>::ImageNPP(const npp::Image::Size&) [with D = unsigned char, unsigned int N = 4u]
./common/ImagesNPP.h:40:13: note: no known conversion for argument 1 from ‘Npp8u* {aka unsigned char*}’ to ‘const npp::Image::Size&’
./common/ImagesNPP.h:35:13: note: npp::ImageNPP<D, N>::ImageNPP(unsigned int, unsigned int, bool) [with D = unsigned char, unsigned int N = 4u]
./common/ImagesNPP.h:35:13: note: candidate expects 3 arguments, 1 provided
./common/ImagesNPP.h:30:13: note: npp::ImageNPP<D, N>::ImageNPP() [with D = unsigned char, unsigned int N = 4u]
./common/ImagesNPP.h:30:13: note: candidate expects 0 arguments, 1 provided
npp_filters.cpp:39:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
なにが問題ですか?正しい方法を教えていただけますか?
今、私のコードは次のようになります。
// declare a host image object for an 8-bit RGBA image
npp::ImageCPU_8u_C4 oHostSrc(width, height);
// copy data to oHostSrc.data()
Npp8u *nDstData = oHostSrc.data();
memcpy(nDstData, data, size * sizeof(Npp8u));
// declare a device image and copy construct from the host image,
// i.e. upload host to device
npp::ImageNPP_8u_C4 oDeviceSrc(oHostSrc);
しかし、今ではデバイス イメージとコピー (最後の行) を宣言できず、そのようなエラーが発生します: undefined symbol: nppiMalloc_8u_C4。それは何ですか?