用vs2010编译vigra静态库及简单使用举例

1、  从 http://ukoethe.github.io/vigra/ 下载最新源代码vigra-1.10.0-src-with-docu.tar.gz,并加压缩到D:\soft\vigra,生成vigra-1.10.0文件夹;

2、  从http://www.cmake.org/cmake/resources/software.html下载CMake并安装;

3、  打开CMake,Where is thesource code: D:/soft/vigra/vigra-1.10.; Where to build the binaries: D:/soft/vigra/;

4、  点击Configure,-->Specify the generator for this project:Visual Studio 10, Use default nativecompilers, 点击finish;

5、  将VIGRA_STATIC_LIB勾选,点击Generate,如果有红色框出现,再次点击Generate即可;

6、  打开vs2010下的vigra.sln工程,首先选中vigraimpex工程,属性中的RuntimeLibrary,release下改为Multi-threaded(/MT),debug下改为Multi-threaded Debug(/MTd),然后分别在Debug和Release下选SolutionExplorer中的Solution ‘vigra’工程,点击右键,运行”Rebuild Solution”,会在D:\soft\vigra\vs2010\src\impex目录下生成Debug/vigraimpex.lib和/Release/vigraimpex.lib ;

7、新建一个控制台工程TestVigra, (1)、在debug下,将Code Generation下的Runtime Library改为Multi-threaded Debug(/MTd), 在release下,将Runtime Library 改为Multi-threaded(/MT) ;(2)、分别在debug和release下,在vc++ directories中,Include directories: D:\soft\vigra\vigra-1.10.0\include; (3)、分别在debug和release下,属性C/C++的Additional Include Directories:D:\soft\vigra\vigra-1.10.0\include; Preprocessor的Preprocessor Definitions: VIGRA_STATIC_LIB;(4)、属性中Character Set: Use Multi-Byte Character Set

stdafx.h:

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>

#include "vigra/stdimage.hxx"
#include "vigra/impex.hxx"//Image import and export functions
#include "vigra/edgedetection.hxx"

using namespace vigra;

// TODO: reference additional headers your program requires here

stdafx.cpp:

// stdafx.cpp : source file that includes just the standard includes
// TestVigra.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

#ifdef _DEBUG
	#pragma comment(lib, "D:/soft/vigra/vs2010/src/impex/Debug/vigraimpex.lib")
#else
	#pragma comment(lib, "D:/soft/vigra/vs2010/src/impex/Release/vigraimpex.lib")
#endif

main.cpp:

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{
	try {
		cout<<"supported formats: "<<vigra::impexListFormats()<<endl;

		string strImageName = "base.bmp";
		string strOutImage  = "new.bmp";

		ImageImportInfo info(strImageName.c_str(), 0);//read image
		//vigra_precondition(info.isGrayscale(), "Sorry, cannot operate on color images");

		double threshold=200, scale=0.5;

		if (info.isGrayscale()) {
			BImage out(info.width(), info.height()); // create a gray scale image of appropriate size
			BImage in(info.width(), info.height());

			importImage(info, destImage(in));

			out = 255;// paint output image white

			importImage(info, destImage(out));// import the image just read

			//differenceOfExponentialEdgeImage(srcImageRange(in), destImage(out), scale, threshold, 0);
			//cannyEdgeImage(srcImageRange(in), destImage(out), scale, threshold, 0);// call edge detection algorithm
			transformImage(srcImageRange(in), destImage(out), linearIntensityTransform(-1, -255));//invert image
			exportImage(srcImageRange(out), ImageExportInfo(strOutImage.c_str()));// write the image to the file
		} else {
			BRGBImage out(info.width(), info.height());// create a RGB image of appropriate size
			BRGBImage in(info.width(), info.height());

			importImage(info, destImage(out));
			importImage(info, destImage(in));

			//RGBValue<int> offset(-255, -255, -255);
			//transformImage(srcImageRange(in), destImage(out), linearIntensityTransform(-1, offset));

			double sizefactor = 1.2;

			int nw = (int)(sizefactor*(info.width()-1) + 1.5); // calculate new image size
			int nh = (int)(sizefactor*(info.height()-1) + 1.5);

			BRGBImage out1(nw, nh);
			resizeImageSplineInterpolation(srcImageRange(in), destImageRange(out1));// resize the image, using a bi-cubic spline algorithms
			exportImage(srcImageRange(out1), ImageExportInfo(strOutImage.c_str()));
		}

	} catch (StdException &e) {
		cout<<e.what()<<endl;// catch any errors that might have occurred and print their reason
		return 1;
	}

	cout<<"ok!"<<endl;

	return 0;
}

用vs2010编译vigra静态库及简单使用举例,布布扣,bubuko.com

时间: 2024-08-05 19:37:37

用vs2010编译vigra静态库及简单使用举例的相关文章

VS2010 编译安装boost库

实践是最好的办法..学习C++,想试试线程,然后打算用boost库,结果boost库编译差点吓到我..没看到比较完整的安装教程..一直耽搁.今天动手.完成了.方法记录如下:1.下载boost从boost官网( http://www.boost.org )上下载最新的boost版本,现在最新是1.49版本,解压到自定义目录(我解压到了D:/program files,最终的目录结构是D:\Program Files\boost_1_49_0) 2.编译安装 在D:\Program Files\bo

Mac下编译libpomelo静态库,并在cocos2dx项目中引用

最近在学习cocos2dx的过程中需要和服务器进行交互,所以这几天在学习libpomelo静态库的编译和使用.之前在windows系统下编译libpomelo,并在VS中引入比较顺利:但是,目前对Mac系统和XCode不是很熟悉,所以多花了些时间.不过,最终还是成功了,在这里就将我编译引入libpomelo静态库的过程记录下来,也分享给和我一样遇到问题的朋友们. 准备工作 libpomelo下载地址:https://github.com/NetEase/libpomelo或者http://pan

C++开发新版本vs使用旧版本vs编译的静态库动态库

关于vs潜在的升级问题概述 (Visual C++)查看官网的介绍:潜在的升级问题概述 (Visual C++).主要问题: 1. 如果使用 /GL(全程序优化)进行编译,则生成的对象文件只能使用生成它时所用的同一工具集进行链接.即若在编译静态库时开启了全程序优化,那么编译出的静态库不可移植. 2. 在 Visual Studio 2013 及更低版本中,不能保证使用不同编译器工具集和运行时库版本生成的对象文件 (OBJ).静态库 (LIB).动态库 (DLL) 和可执行文件 (EXE) 之间的

win7下vs2010编译使用静态和动态库

知识补充: sqlite3.dll动态链接库,它允许程序共享执行特殊任务所必需的代码和其他资源. 动态的sqlite3.lib相当于一个h文件,是对实现部分(.dll文件)的导出部分的声明.编译后只是将导出声明部分编译到宿主程序中,其生成的sqlite3.exe在运行时需要相应的dll文件支持 . 静态的sqlite3.lib将导出声明和实现都放在lib中.编译后所有代码都嵌入到宿主程序,其生成的sqlite3.exe可直接运行. 任务: 一.使用VS2010编译sqlite3,生成动态的sql

zlib-1.2.8用VS2010编译生成动态静态库

1.官网下载地址 http://zlib.net/zlib128.zip 2.解压到指定目录 例如:E:\zlib-1.2.8 目录的内容如下: 3.在开始菜单中找到<Visual Studio命令提示(2010)> 单击,打开 4.利用命令进入到上面解压的目录 5.接着,进入E:\zlib-1.2.8\contrib 利用windows资源管理器打开对应的目录,可以看到,其中的内容如下 这里针对不同环境选择不同的编译环境 6.这里选择32位的环境,所以进入masmx86目录 7.执行bld_

项目中遇到的问题-2:编译第三方静态库报错、查看静态库的类型、绘制圆形

这一周比较折腾,由于项目应用涉及到和其他产品线APP的互相通信,在高层领导英(yi)明(ta)神(hu)武(tu)的战略指导下,我开始了与其他组同事的联调之旅.这几天鄙司负责产品的上级同事莅临监工,对现在的情况又提出了一些改进,作为一名程序猿,我已经奉上我的双膝... 一.集成公司其他组的.a静态库,报错:duplicate symbole for architectecture i386 XXX  查了一下报错的地方,都是指示.a的库和工程里面某些.m文件冲突,正好同事提到之前有碰到过这种情况

Mac OS X10.10_xcode6.1_ios8.1环境下,编译lame静态库libmp3lame.a,支持arm64 armv7s x86_64 i386 armv7指令集

最近升级了系统到Mac OS X 10.10 并且更新了XCode6.1和iOS 8.1之前app用到的libmp3lame.a静态库,也要支持64位的模拟器(x86_64)和64位的真机(arm64)指令集.需要重新编译查阅了下资料,按照如下步骤,并做了些注释和改动 1.http://sourceforge.net/projects/lame/files/lame/3.99/ 下载lame的最新版本解压到一个文件夹里例如 lame,全路径如下/Users/8wm/Desktop/lame 2.

ORTP编译为静态库的问题

项目中需要用到ORTP,我采用的编译环境是 VC2013,当我在项目设置中将设置为静态库是,发现没有导出函数,比如在需要连接 oRTP.lib库时提示 找不到 ORTP_init; 解决办法是 :在ORTP库的项目中和需要连接ORTP库的项目中 添加预处理器定义  ORTP_STATIC ,就可以了 程序猿们,我也跟风开了网店,主要经营土特产,云南核桃,四川正宗土鸡蛋鸡蛋.有需要的就支持一下小店哈  七彩山川美食(http://qcsc.taobao.com)

vs2010 链接OpenCV 静态库

1. 添加opencv 头文件路径 Properties-> VC++ Directories -> Include Directories += $(OPENCV_INC) 2. runtime library 由dll改为非dll Properties-> c/c++ / Code Generation -> Runtime Library     =   /MT   (默认是/MD ) 3. 添加opencv 库路径 Properties-> Linker->Ge