【前言】

最近,因为需要开发DICOM网管模块,必须使用DCMTK的DcmNet模块。但是DCMTK3.6.0在DcmNet模块中只提供两个实验阶段的网络类DcmSCU和DcmSCP。而且他们并没有完全实现DICOM的C-Echo、C-Find、C-Get、C-Move和C-store操作。只实现了C-Echo和C-Find操作。

调研了一番,发现DCMTK小组在最新的snapshot版本中(DCMTK3.6.1 2012-08-31),已经实现了DICOM全部操作。而且他们官方论坛中,开发人员在回答疑问时候,针对3.6.0中出现的bug等问题。他们也是鼓励大家直接用最新的DCMTK3.6.1.

当然他们也建议大家自己去通过底层代码实现DcmScu的其他的操作。不过对于我们这种新手来讲确实很困难,而且关键问题在后期的3.6.1版本的代码变化很大。我们自己手写的,以后不方便兼容。

所以最终我还是下载了最新的DCMTK3.6.1-20120831,但是他有一个问题,目前只支持在linux上编译和运行。windows环境,他们并没有提供支持库。于是又让我踌躇了一番,自己也手动试着基于3.6.0写了点代码,但是真的是超级难。最终下定决心在win7上编译3.6.1,并利用DCMTK3.6.0的support(MD)Library。在DCMTK官方论坛开发人员的帮助下,最终编译成功。也实现DcmScu的例子网络访问。

【开发环境】

操作系统:win7 32bit

开发工具:VS2008 + Qt4.7.4

1、DCMTK: DCMTK3.6.120120831

2、DCMTK support libraries for windows: dcmtk-3.6.0-win32-i386-support_MD.zip

3、CMake:cmake-2.8.9-win32-x86.exe

目前我的Qt项目都是基于MD/MDd的运行时库。

【安装过程】

1、将支持库中的相应lib文件,include文件,bin文件拷贝到VS2008安装目录的相应文件夹下。

A.在解压得到的支持库的文件夹下搜索_d.lib文件(xxx_d.lib为DEBUG版本的支持库,xxx_o.lib为RELEASE版本支持库),应该会得到7个结果,将这些文件复制到一个单独的文件夹下,并把它们的名字中的_d去掉,例如将zlib_d.lib重命名为zlib.lib。将重命名后的文件拷贝至VS2008安装目录下的lib文件夹下,在我的win7 32bit电脑上是C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\
 
B.在解压得到的支持库的文件夹下搜索include,应该得到5个文件夹,将这些文件夹复制到C:\Program Files\Microsoft Visual Studio 9.0\VC\下,选择合并文件夹,也就是将include文件夹下的内容全部复制到C:\Program Files\Microsoft Visual Studio 9.0\VC\include\目录下。
 
C.将D:\DCMTK\dcmtk-3.6.0-win32-i386-support_MD\openssl-1.0.0c\bin下的五个文件复制到C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\下。

2、CMake编译

A、设置source code 路径: D:\DCMTK\dcmtk-3.6.1_20120831

B、设置binaries路径: D:\DCMTK\DCMTK-bin

C、选择Configure:visual studio 9 2008

D、等待configure完毕后,会有很多find和not find,无所谓。

E、选中Advanced单选框,然后在红色区域设置:

set DCMTK_OVERWRITE_WIN32_COMPILER_FLAG = OFF;(不选中,这样可以使生成项目运行时库都是MD/MDd,而不是默认的MT/MTd)

set "DCMTK_WITH_ICONV" to "ON" (选中)

set "DCMTK_WITH_OPENSSL" to "ON"(选中)

set "DCMTK_WITH_PNG" to "ON" (选中)

set "DCMTK_WITH_TIFF" to "ON" (选中)

set "DCMTK_WITH_XML" to "ON" (选中)

set "DCMTK_WITH_ZLIB" to "ON" (选中)

F、点击Generate,很快就完成。这时候VS项目源码已经生成。

3、VS2008编译项目源码

A、用VS打开 D:\DCMTK\DCMTK-bin\DCMTK.sln

B、点击Build->Batch Build,选择ALL_BUILD项目的debug版,点击右边的Build。耐心等待。会有很多个warning,应该是由字符编码不统一引起的。最后会看到82个编译 成功,0个失败。

C、再选择Build->Batch Build,这次选择INSTALL项目的debug版本,点击右边的Build。最后会显示1个工程编译成功,这时在你选择的安装目录下(默认是C:\Program Files\DCMTK)就会有lib,bin,include,etc,share文件夹,里面就是之后写程序做医学图像处理所需要的库文件了

4、代码测试

A. 新建一个Qt application,把以上源代码复制粘贴进main.cpp去。
B. 右键单击工程名,选择属性(properties),在Configuration Properties->C/C++->General下,
Additional Include Directories里加入上一步编译出来的include文件夹,我的Win7 32bit电脑上是
C:\Program Files\DCMTK\include,这一步是为了让程序能够找到头文件。
C. C/C++->code generation里,Runtime Library 选择/MDd,这一步是要和之前CMAKE的编译选项一致。
(我的Qt项目默认就是/MDd)
D. Linker->General里,Additional Library Directories里填写上一步编译出来的lib文件夹,我的Win7 32bit
电脑上是C:\Program Files\DCMTK\lib,这一步是为了让程序能够找到之前编译好的lib文件。
E. Linker->Input里,在Additional Dependencies 里依次加上
wsock32.lib
netapi32.lib
ofstd.lib
oflog.lib
dcmdata.lib
dcmnet.lib
zlib.lib
这一步是加入具体我们程序需要的lib文件。

F. Debug,ok,编译工程,运行成功。访问了www.dicomserver.co.uk的DICOM服务器。

源代码如下:

The code uses the public DICOM server at www.dicomserver.co.uk which is offered by Dave Harvey (MedicalObjects). There are also logs you can check at the server in order to debug your application.

/*
*
* Copyright (C) 2011-2012, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmnet
*
* Author: Michael Onken
*
* Purpose: Test for move feature of the DcmSCU class
*/ #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmnet/testscu.h"
#include "dcmtk/dcmnet/diutil.h" #define OFFIS_CONSOLE_APPLICATION "testscu" static OFLogger echoscuLogger = OFLog::getLogger("dcmtk.apps." OFFIS_CONSOLE_APPLICATION); static char rcsid[] = "$dcmtk: " OFFIS_CONSOLE_APPLICATION " v"
OFFIS_DCMTK_VERSION " " OFFIS_DCMTK_RELEASEDATE " $"; // our application entity title used for calling the peer machine
#define APPLICATIONTITLE "TEST-SCU" // host name of the peer machine
#define PEERHOSTNAME "www.dicomserver.co.uk" // TCP/IP port to connect to the peer machine
#define PEERPORT 11112 // application entity title of the peer machine
#define PEERAPPLICATIONTITLE "MOVESCP" // MOVE destination AE Title
#define MOVEAPPLICATIONTITLE "TEST-SCU" static Uint8 findUncompressedPC(const OFString& sopClass,
DcmSCU& scu)
{
Uint8 pc;
pc = scu.findPresentationContextID(sopClass, UID_LittleEndianExplicitTransferSyntax);
if (pc == 0)
pc = scu.findPresentationContextID(sopClass, UID_BigEndianExplicitTransferSyntax);
if (pc == 0)
pc = scu.findPresentationContextID(sopClass, UID_LittleEndianImplicitTransferSyntax);
return pc;
} // ******************************************** int main(int argc, char *argv[])
{
/* Setup DICOM connection parameters */
OFLog::configure(OFLogger::DEBUG_LOG_LEVEL);
DcmTestSCU scu;
// set AE titles
scu.setAETitle(APPLICATIONTITLE);
scu.setPeerHostName(PEERHOSTNAME);
scu.setPeerPort(PEERPORT);
scu.setPeerAETitle(PEERAPPLICATIONTITLE);
// Use presentation context for FIND/MOVE in study root, propose all uncompressed transfer syntaxes
OFList<OFString> ts;
ts.push_back(UID_LittleEndianExplicitTransferSyntax);
ts.push_back(UID_BigEndianExplicitTransferSyntax);
ts.push_back(UID_LittleEndianImplicitTransferSyntax);
scu.addPresentationContext(UID_FINDStudyRootQueryRetrieveInformationModel, ts);
scu.addPresentationContext(UID_MOVEStudyRootQueryRetrieveInformationModel, ts);
scu.addPresentationContext(UID_VerificationSOPClass, ts); /* Initialize network */
OFCondition result = scu.initNetwork();
if (result.bad())
{
DCMNET_ERROR("Unable to set up the network: " << result.text());
return 1;
} /* Negotiate Association */
result = scu.negotiateAssociation();
if (result.bad())
{
DCMNET_ERROR("Unable to negotiate association: " << result.text());
return 1;
} /* Let's look whether the server is listening:
Assemble and send C-ECHO request
*/
result = scu.sendECHORequest(0);
if (result.bad())
{
DCMNET_ERROR("Could not process C-ECHO with the server: " << result.text());
return 1;
} /* Assemble and send C-FIND request */
OFList<QRResponse*> findResponses;
DcmDataset req;
req.putAndInsertOFStringArray(DCM_QueryRetrieveLevel, "STUDY");
req.putAndInsertOFStringArray(DCM_StudyInstanceUID, "");
T_ASC_PresentationContextID presID = findUncompressedPC(UID_FINDStudyRootQueryRetrieveInformationModel, scu);
if (presID == 0)
{
DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND");
return 1;
}
result = scu.sendFINDRequest(presID, &req, &findResponses);
if (result.bad())
return 1;
else
DCMNET_INFO("There are " << findResponses.size() << " studies available"); /* Assemble and send C-MOVE request, for each study identified above*/
presID = findUncompressedPC(UID_MOVEStudyRootQueryRetrieveInformationModel, scu);
if (presID == 0)
{
DCMNET_ERROR("There is no uncompressed presentation context for Study Root MOVE");
return 1;
}
OFListIterator(QRResponse*) study = findResponses.begin();
Uint32 studyCount = 1;
OFBool failed = OFFalse;
// Every while loop run will get all image for a specific study
while (study != findResponses.end() && result.good())
{
// be sure we are not in the last response which does not have a dataset
if ( (*study)->m_dataset != NULL)
{
OFString studyInstanceUID;
result = (*study)->m_dataset->findAndGetOFStringArray(DCM_StudyInstanceUID, studyInstanceUID);
// only try to get study if we actually have study instance uid, otherwise skip it
if (result.good())
{
req.putAndInsertOFStringArray(DCM_StudyInstanceUID, studyInstanceUID);
// fetches all images of this particular study
result = scu.sendMOVERequest(presID, MOVEAPPLICATIONTITLE, &req, NULL /* we are not interested into responses*/);
if (result.good())
{
DCMNET_INFO("Received study #" << std::setw(7) << studyCount << ": " << studyInstanceUID);
studyCount++;
}
}
}
study++;
}
if (result.bad())
{
DCMNET_ERROR("Unable to retrieve all studies: " << result.text());
}
while (!findResponses.empty())
{
delete findResponses.front();
findResponses.pop_front();
}
/* Release association */
scu.closeAssociation(DCMSCU_RELEASE_ASSOCIATION);
return 0;
}

P.S: The header file would be trivial:

#ifndef TESTSCU_H
#define TESTSCU_H #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "dcmtk/dcmnet/scu.h" /* Covers most common dcmdata classes */ class DcmTestSCU : public DcmSCU
{ public: DcmTestSCU() {}
~DcmTestSCU() {} }; #endif // TESTSCU_H

参考文章:

1、DcmSCU example program

2、DCMTK3.6.0(MD支持库)安装说明

3、how to use DCMTK 3.6.1 on win7

------------------------------------

柳北风儿

http://qimo601.iteye.com

------------------------------------

DCMTK3.6.1编译失败总结

针对DCMTK3.6.1 编译的错误总结:

1、完全默认CMake配置, DCMTK编译成功。但无支持库externallibraries (OpenSSL, zlib, libtiff, libpng, libxml2 and libiconv)

结果:如果不加支持库,运行网上例子,肯定出错。1>Linking...1> LINK : fatal error LNK1181: cannot open input file 'zlib.lib'

2、设置了MD支持库,在VC里配置好文件,手动修改CMakeList.txt为MD/MDd。会出现如下错误:warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use等运行时库冲突错误。

3、按照DCMTK官方编译方法失败。官方配置CMake属性,加上3.6.0MD支持库,

libpng support:
set "DCMTK_WITH_PNG" to "ON" and
set "WITH_LIBPNGINC" e.g. to "C:\libpng-1.4.2"

libtiff support:
set "DCMTK_WITH_TIFF" to "ON" and
set "WITH_LIBTIFFINC" e.g. to "C:\tiff-3.9.2"

OpenSSL support:
set "DCMTK_WITH_OPENSSL" to "ON" and
set "WITH_OPENSSLINC" e.g. to "C:\openssl-1.0.0"

zlib support:
set "DCMTK_WITH_ZLIB" to "ON" and
set "WITH_ZLIBINC" e.g. to "C:\zlib-1.2.5"

libiconv support:
set "DCMTK_WITH_ICONV" to "ON" and
set "WITH_LIBICONVINC" e.g. to "C:\libiconv-1.14"
以及设置DCMTK_OVERWRITE_WIN32_COMPILER_FLAG = OFF;

缺少libiconv的编译后的支持库。

最后还是按照如上方法,完全实现DCMTK3.6.1在win7上的编译。

DCMTK3.6.1(MD支持库)安装说明的更多相关文章

  1. DCMTK3.6.0(MD支持库)安装说明

    一.运行环境:WIN7 32bit + VisualStudio2008 + dcmtk3.6.0 + Cmake2.8.8 或者 WIN7 64bit 二.准备工作: 1)MD/MT的知识储备: / ...

  2. DCMTK3.6.0 (MT支持库)安装 完整说明

    环境WIN7 + VisualStudio2010 + dcmtk3.6.0 + Cmake2.8.6 准备工作: 从dcmtk官方网站下载源代码及支持库文件.分别名为:dcmtk-3.6.0 dcm ...

  3. Linux下安装PHP的GD支持库

    Linux下安装PHP的GD支持库   1.安装 zlib  wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/zlib-1.2.3.tar.gz ...

  4. linux中必备常用支持库的安装(CentOS)

    在CentOS安装软件的时候,可能缺少一部分支持库,而报错.这里首先安装系统常用的支持库.那么在安装的时候就会减少很多的错误的出现 yum install -y gcc gdb strace gcc- ...

  5. phpize 扩展GD库 安装 ! 环境--centos 7 +nginx 1.7.11+php 5.6.7

    使用phpize编译GD库安装,先安装前置库libjpeg libpng zlib  freetype等 都是下面php编译的几个选项 先看php编译的选项: --with-gd=DIR       ...

  6. Windows2003/2008/2008 R2下易语言点支持库配置就退出的问题

    问题: 请问一个问题,我的电脑上win2003系统的,安装了易语言后,一点支持库配置就会自动退出.这是为什么啊? 解决方法如下: 删除 lib下的wmp.npk,重新打开易语言就可以了.

  7. sqlserver 无法初始化via支持库[QLVIPL.DLL]

    安装数据库后,在sqlserver configuration manager, sqlserver的网络配置,有将协议 shared memory,named pipes,tcp/ip,via全部启 ...

  8. centos 6.5常见lib库安装

    在CentOS安装软件的时候,可能缺少一部分支持库,而报错.这里首先安装系统常用的支持库.那么在安装的时候就会减少很多的错误的出现. # yum install -y gcc gdb strace g ...

  9. 双心一键获取winsxs的写入权限,解决VC运行库安装error1935错误

    @Echo offtitle 双心一键获取winsxs的写入权限,解决VC运行库安装error1935等错误set path=%path%;%~dp0setlocal EnableDelayedExp ...

随机推荐

  1. shell中的正则表达式

    1.正则与通配符 linux中的通配符是用来匹配文件名的,其匹配是完全匹配.只支持通配符则命令有ls find cp等命令 正则是用来匹配字符串的,是包含匹配.只要搜索的内容在某个字符串中,那么改字符 ...

  2. 年前辞职-WCF入门学习(4)

    前言 上一篇的学习中碰到一个问题,用地址http://localhost:8080/mex 访问元数据的时候一直提示400 bad request 错误,因为时间太晚了,查了好几遍代码,也没有发现问题 ...

  3. javascript继承(一)—类的属性研究

    本篇文章主要针对javascript的属性进行分析,由于javascript是一种基于对象的语言,本身没有类的概念,所以对于javascript的类的定义有很多名字,例于原型对象,构造函数等,它们都是 ...

  4. Set up gradle HiveMind

    HiveMind is a comprehensive ERP application for service organizations. It includes a project managem ...

  5. eclipse&android的环境搭建

    这次我选择使用Android来完成这次软件工程实践,不过配置eclipse和android环境真是个麻烦事. 因为之前有用过eclipse,对其比较熟悉,于是就放弃了android studio这个工 ...

  6. FusionCharts的使用方法

    来源于:http://www.cnblogs.com/xuhongfei/archive/2013/04/12/3016882.html 今天统计价格变化规律的时候找到的一个很好的文档,很详细 一.简 ...

  7. Struts-1和2的比较

    Struts1和Struts2都是MVC设计模式的经典应用框架,下文从代码,性能,测试,功能等方面对Struts1和Struts2进行简单比较,来看看Struts的高级版本在哪些方面进行了优化. (1 ...

  8. 4.Android下拉列表框spinner学习

    下拉列表框被广泛使用,诸如淘宝.京东等手机端经常可以看到这个部件身影,今天就来学习下它. 首先布局文件增加代码:如图 接下来在values下增加arrays.xml 如图               ...

  9. Windows下python的配置

    Windows下python的配置 希望这是最后一次写关于python的配置博客了,已经被python的安装烦的不行了.一开始我希望安装python.手动配置pip并使用pip安装numpy,然而发现 ...

  10. POJ3038 Flying Right

    Description Figuring that they cannot do worse than the humans have, Farmer John's cows have decided ...