-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (39 loc) · 1.45 KB
/
main.cpp
File metadata and controls
55 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* The basic example program just takes one DCM image and reads a patient's name from it.
*
* For more information go to: https://github.com/marcinwol/dcmtk-basic-example
*/
#include <iostream>
#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmimgle/dcmimage.h"
using namespace std;
int main(int argc, const char *argv[]) {
string root_path;
// SOURCE_CODE_LOCATION is set by cmake during compilation.
// this contains the path to the source folder.
// This is only helper for convenience. Without this
// in_file below should contain absolute path.
#ifdef SOURCE_CODE_LOCATION
root_path = SOURCE_CODE_LOCATION;
#endif
// where does this example dcm come from, is
// is explained at https://github.com/marcinwol/dcmtk-basic-example
string in_file {root_path + "/DCMIMAGES/77654033/20010101/CR1/6154"};
DcmFileFormat file_format;
OFCondition status = file_format.loadFile(in_file.c_str());
if (status.bad()) {
cerr << "Problem openning file:" << in_file << endl;
return 1;
}
DcmDataset* dataset = file_format.getDataset();
OFString patient_name;
OFCondition condition;
condition = dataset->findAndGetOFStringArray(DCM_PatientName, patient_name);
if (condition.good()) {
cout << "Patient name is: " << patient_name << endl;
} else {
cerr << "Could not get patient name" << endl;
}
cout << "Program finish." << endl;
return 0;
}