Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t链接库 我试图用微软Visual Studio 2017。C++编写程序。 #include "stdafx.h" #include <opencv2/core/core.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <iostream> #include <string> extern "C" { #include "libtiff/libtiff/tiffio.h" } using namespace cv; using namespace std; int main(int argc, char** argv) { string imageName("410.tif"); // start with a default // If there is an argument, read it in as the name of the image if (argc > 1) { imageName = argv[1]; } // Open the TIFF file using libtiff TIFF* tif = TIFFOpen(imageName.c_str(), "r"); // Create a matrix to hold the tif image in Mat image; // check the tif is open if (tif) { do { unsigned int width, height; uint32* raster; // get the size of the tiff TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); uint npixels = width * height; // get the total number of pixels raster = (uint32*)_TIFFmalloc(npixels * sizeof(uint32)); // allocate temp memory (must use the tiff library malloc) if (raster == NULL) // check the raster's memory was allocaed { TIFFClose(tif); cerr << "Could not allocate memory for raster of TIFF image" << endl; return -1; } // Check the tif read to the raster correctly if (!TIFFReadRGBAImage(tif, width, height, raster, 0)) { TIFFClose(tif); cerr << "Could not read raster of TIFF image" << endl; return -1; } image = Mat(width, height, CV_8UC4); // create a new matrix of w x h with 8 bits per channel and 4 channels (RGBA) // itterate through all the pixels of the tif for (uint x = 0; x < width; x++) for (uint y = 0; y < height; y++) { uint32& TiffPixel = raster[y*width + x]; // read the current pixel of the TIF Vec4b& pixel = image.at<Vec4b>(Point(y, x)); // read the current pixel of the matrix pixel[0] = TIFFGetB(TiffPixel); // Set the pixel values as BGRA pixel[1] = TIFFGetG(TiffPixel); pixel[2] = TIFFGetR(TiffPixel); pixel[3] = TIFFGetA(TiffPixel); } _TIFFfree(raster); // release temp memory // Rotate the image 90 degrees couter clockwise image = image.t(); flip(image, image, 0); imshow("TIF Image", image); // show the image waitKey(0); // wait for anykey before displaying next } while (TIFFReadDirectory(tif)); // get the next tif TIFFClose(tif); // close the tif file } return 0; } #包括“stdafx.h” #包括 #包括 #包括 #包括 #包括 #包括 外部“C”{ #包括“libtiff/libtiff/tiffio.h” } 使用名称空间cv; 使用名称空间std; int main(int argc,字符**argv) { 字符串imageName(“410.tif”);//以默认值开头 //如果有参数,请将其作为图像的名称读入 如果(argc>1) { imageName=argv[1]; } //使用libtiff打开TIFF文件 TIFF*tif=TIFFOpen(imageName.c_str(),“r”); //创建用于保存tif图像的矩阵 Mat图像; //检查tif是否打开 如果(tif){ 做{ 无符号整数宽度、高度; uint32*光栅; //获取tiff的大小 TIFFGetField(tif、TIFFTAG_图像宽度和宽度); TIFFGetField(tif、TIFFTAG_图像长度和高度); uint npixels=width*height;//获取像素总数 光栅=(uint32*)_TIFFmalloc(npixels*sizeof(uint32));//分配临时内存(必须使用tiff库malloc) 如果(光栅==NULL)//检查光栅的内存是否已分配 { TIFFClose(tif); CERP R P> TIFF是C库,而你的程序是C++,C++和C有不同的链接ABIS。 当你使用C++源代码库时,你应该做一些类似的事情: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end ……用C++表示符号遵循C abi。< /p> 注< /St>:许多广泛使用的C库包括在它们的头内的C++条件预处理器检查,以避免这个问题,例如: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end_C++_Libtiff - Fatal编程技术网 1) { imageName=argv[1]; } //使用libtiff打开TIFF文件 TIFF*tif=TIFFOpen(imageName.c_str(),“r”); //创建用于保存tif图像的矩阵 Mat图像; //检查tif是否打开 如果(tif){ 做{ 无符号整数宽度、高度; uint32*光栅; //获取tiff的大小 TIFFGetField(tif、TIFFTAG_图像宽度和宽度); TIFFGetField(tif、TIFFTAG_图像长度和高度); uint npixels=width*height;//获取像素总数 光栅=(uint32*)_TIFFmalloc(npixels*sizeof(uint32));//分配临时内存(必须使用tiff库malloc) 如果(光栅==NULL)//检查光栅的内存是否已分配 { TIFFClose(tif); CERP R P> TIFF是C库,而你的程序是C++,C++和C有不同的链接ABIS。 当你使用C++源代码库时,你应该做一些类似的事情: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end ……用C++表示符号遵循C abi。< /p> 注< /St>:许多广泛使用的C库包括在它们的头内的C++条件预处理器检查,以避免这个问题,例如: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end,c++,libtiff,C++,Libtiff" /> 1) { imageName=argv[1]; } //使用libtiff打开TIFF文件 TIFF*tif=TIFFOpen(imageName.c_str(),“r”); //创建用于保存tif图像的矩阵 Mat图像; //检查tif是否打开 如果(tif){ 做{ 无符号整数宽度、高度; uint32*光栅; //获取tiff的大小 TIFFGetField(tif、TIFFTAG_图像宽度和宽度); TIFFGetField(tif、TIFFTAG_图像长度和高度); uint npixels=width*height;//获取像素总数 光栅=(uint32*)_TIFFmalloc(npixels*sizeof(uint32));//分配临时内存(必须使用tiff库malloc) 如果(光栅==NULL)//检查光栅的内存是否已分配 { TIFFClose(tif); CERP R P> TIFF是C库,而你的程序是C++,C++和C有不同的链接ABIS。 当你使用C++源代码库时,你应该做一些类似的事情: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end ……用C++表示符号遵循C abi。< /p> 注< /St>:许多广泛使用的C库包括在它们的头内的C++条件预处理器检查,以避免这个问题,例如: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end,c++,libtiff,C++,Libtiff" />

Can';t链接库 我试图用微软Visual Studio 2017。C++编写程序。 #include "stdafx.h" #include <opencv2/core/core.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <iostream> #include <string> extern "C" { #include "libtiff/libtiff/tiffio.h" } using namespace cv; using namespace std; int main(int argc, char** argv) { string imageName("410.tif"); // start with a default // If there is an argument, read it in as the name of the image if (argc > 1) { imageName = argv[1]; } // Open the TIFF file using libtiff TIFF* tif = TIFFOpen(imageName.c_str(), "r"); // Create a matrix to hold the tif image in Mat image; // check the tif is open if (tif) { do { unsigned int width, height; uint32* raster; // get the size of the tiff TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); uint npixels = width * height; // get the total number of pixels raster = (uint32*)_TIFFmalloc(npixels * sizeof(uint32)); // allocate temp memory (must use the tiff library malloc) if (raster == NULL) // check the raster's memory was allocaed { TIFFClose(tif); cerr << "Could not allocate memory for raster of TIFF image" << endl; return -1; } // Check the tif read to the raster correctly if (!TIFFReadRGBAImage(tif, width, height, raster, 0)) { TIFFClose(tif); cerr << "Could not read raster of TIFF image" << endl; return -1; } image = Mat(width, height, CV_8UC4); // create a new matrix of w x h with 8 bits per channel and 4 channels (RGBA) // itterate through all the pixels of the tif for (uint x = 0; x < width; x++) for (uint y = 0; y < height; y++) { uint32& TiffPixel = raster[y*width + x]; // read the current pixel of the TIF Vec4b& pixel = image.at<Vec4b>(Point(y, x)); // read the current pixel of the matrix pixel[0] = TIFFGetB(TiffPixel); // Set the pixel values as BGRA pixel[1] = TIFFGetG(TiffPixel); pixel[2] = TIFFGetR(TiffPixel); pixel[3] = TIFFGetA(TiffPixel); } _TIFFfree(raster); // release temp memory // Rotate the image 90 degrees couter clockwise image = image.t(); flip(image, image, 0); imshow("TIF Image", image); // show the image waitKey(0); // wait for anykey before displaying next } while (TIFFReadDirectory(tif)); // get the next tif TIFFClose(tif); // close the tif file } return 0; } #包括“stdafx.h” #包括 #包括 #包括 #包括 #包括 #包括 外部“C”{ #包括“libtiff/libtiff/tiffio.h” } 使用名称空间cv; 使用名称空间std; int main(int argc,字符**argv) { 字符串imageName(“410.tif”);//以默认值开头 //如果有参数,请将其作为图像的名称读入 如果(argc>1) { imageName=argv[1]; } //使用libtiff打开TIFF文件 TIFF*tif=TIFFOpen(imageName.c_str(),“r”); //创建用于保存tif图像的矩阵 Mat图像; //检查tif是否打开 如果(tif){ 做{ 无符号整数宽度、高度; uint32*光栅; //获取tiff的大小 TIFFGetField(tif、TIFFTAG_图像宽度和宽度); TIFFGetField(tif、TIFFTAG_图像长度和高度); uint npixels=width*height;//获取像素总数 光栅=(uint32*)_TIFFmalloc(npixels*sizeof(uint32));//分配临时内存(必须使用tiff库malloc) 如果(光栅==NULL)//检查光栅的内存是否已分配 { TIFFClose(tif); CERP R P> TIFF是C库,而你的程序是C++,C++和C有不同的链接ABIS。 当你使用C++源代码库时,你应该做一些类似的事情: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end ……用C++表示符号遵循C abi。< /p> 注< /St>:许多广泛使用的C库包括在它们的头内的C++条件预处理器检查,以避免这个问题,例如: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end

Can';t链接库 我试图用微软Visual Studio 2017。C++编写程序。 #include "stdafx.h" #include <opencv2/core/core.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <iostream> #include <string> extern "C" { #include "libtiff/libtiff/tiffio.h" } using namespace cv; using namespace std; int main(int argc, char** argv) { string imageName("410.tif"); // start with a default // If there is an argument, read it in as the name of the image if (argc > 1) { imageName = argv[1]; } // Open the TIFF file using libtiff TIFF* tif = TIFFOpen(imageName.c_str(), "r"); // Create a matrix to hold the tif image in Mat image; // check the tif is open if (tif) { do { unsigned int width, height; uint32* raster; // get the size of the tiff TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); uint npixels = width * height; // get the total number of pixels raster = (uint32*)_TIFFmalloc(npixels * sizeof(uint32)); // allocate temp memory (must use the tiff library malloc) if (raster == NULL) // check the raster's memory was allocaed { TIFFClose(tif); cerr << "Could not allocate memory for raster of TIFF image" << endl; return -1; } // Check the tif read to the raster correctly if (!TIFFReadRGBAImage(tif, width, height, raster, 0)) { TIFFClose(tif); cerr << "Could not read raster of TIFF image" << endl; return -1; } image = Mat(width, height, CV_8UC4); // create a new matrix of w x h with 8 bits per channel and 4 channels (RGBA) // itterate through all the pixels of the tif for (uint x = 0; x < width; x++) for (uint y = 0; y < height; y++) { uint32& TiffPixel = raster[y*width + x]; // read the current pixel of the TIF Vec4b& pixel = image.at<Vec4b>(Point(y, x)); // read the current pixel of the matrix pixel[0] = TIFFGetB(TiffPixel); // Set the pixel values as BGRA pixel[1] = TIFFGetG(TiffPixel); pixel[2] = TIFFGetR(TiffPixel); pixel[3] = TIFFGetA(TiffPixel); } _TIFFfree(raster); // release temp memory // Rotate the image 90 degrees couter clockwise image = image.t(); flip(image, image, 0); imshow("TIF Image", image); // show the image waitKey(0); // wait for anykey before displaying next } while (TIFFReadDirectory(tif)); // get the next tif TIFFClose(tif); // close the tif file } return 0; } #包括“stdafx.h” #包括 #包括 #包括 #包括 #包括 #包括 外部“C”{ #包括“libtiff/libtiff/tiffio.h” } 使用名称空间cv; 使用名称空间std; int main(int argc,字符**argv) { 字符串imageName(“410.tif”);//以默认值开头 //如果有参数,请将其作为图像的名称读入 如果(argc>1) { imageName=argv[1]; } //使用libtiff打开TIFF文件 TIFF*tif=TIFFOpen(imageName.c_str(),“r”); //创建用于保存tif图像的矩阵 Mat图像; //检查tif是否打开 如果(tif){ 做{ 无符号整数宽度、高度; uint32*光栅; //获取tiff的大小 TIFFGetField(tif、TIFFTAG_图像宽度和宽度); TIFFGetField(tif、TIFFTAG_图像长度和高度); uint npixels=width*height;//获取像素总数 光栅=(uint32*)_TIFFmalloc(npixels*sizeof(uint32));//分配临时内存(必须使用tiff库malloc) 如果(光栅==NULL)//检查光栅的内存是否已分配 { TIFFClose(tif); CERP R P> TIFF是C库,而你的程序是C++,C++和C有不同的链接ABIS。 当你使用C++源代码库时,你应该做一些类似的事情: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end ……用C++表示符号遵循C abi。< /p> 注< /St>:许多广泛使用的C库包括在它们的头内的C++条件预处理器检查,以避免这个问题,例如: extern "C" { #include "libtiff/libtiff/tiffio.h" } #ifdef __cplusplus extern "C" { #endif /* Actual header content */ extern int do_something(void); extern int do_something_else(const char*); /* ... */ #ifdef __cplusplus } #end,c++,libtiff,C++,Libtiff,libtiff并非如此。使用以下库: 我可以正确地包含libtiff,但问题是这个库是64位的,而openCV是32位的。因此我得到以下错误: LNK4272库计算机的“x86”类型与目标计算机ImageManipulation C:\Program Files(x86)\GnuWin32\lib\libtiff.lib 1的“x64”类型冲突 Visual Studio中的平台解决方案设置为x64,因为如果我在x86 openCV上打开它,它将无法工作。由于这些是为了可移植性,您是否需要为您的

libtiff并非如此。

使用以下库: 我可以正确地包含libtiff,但问题是这个库是64位的,而openCV是32位的。因此我得到以下错误:

LNK4272库计算机的“x86”类型与目标计算机ImageManipulation C:\Program Files(x86)\GnuWin32\lib\libtiff.lib 1的“x64”类型冲突


Visual Studio中的平台解决方案设置为x64,因为如果我在x86 openCV上打开它,它将无法工作。

由于这些是为了可移植性,您是否需要为您的平台提供这些或链接到一个版本中?您当时是否有一个原型。也许它们应该是C原型。@WilliamJBagshaw如果它们不是C原型,就不会是erRoR消息显示了一个修饰名?我不知道,问题是这些在C++中不可用吗?我应该如何修复它?我试图添加外部“C”太多了,但什么也没有改变。@Davide57现在很清楚,你没有链接到tiff库。你正在使用的所有函数都没有解析。仅仅包含
#还不够。
你还必须链接。请重新阅读文档。我肯定你是对的,但为什么"u TIFFmalloc"是唯一没有解析的函数。我试图添加你所说的内容,但问题仍然存在em仍然存在。不管怎样@john问题扩展到了所有的“\u”,但我只发布了一个。@David57只是一个猜测,但可能“\u”函数是在另一个库中定义的,一个你没有链接的库?@john问题是关于“\u TIFFMalloc、\u Tiffee、TIFFClose、TIFFGetField、TIFFReadDirectory、TIFFReadRGBAImage、TIFFOpen”。我不知道为什么。。。