Here's a short C++ code snippet that creates a DICOM encapsulated MPEG to start with:
static void CreateVideo(string filename)
{
/// Create a DCXOBJ
IDCXOBJPtr obj(__uuidof(DCXOBJ));
/// Create an element pointer to place in the object for every tag
IDCXELMPtr el(__uuidof(DCXELM));
IDCXUIDPtr id(__uuidof(DCXUID));
rzdcxLib::ENCAPSULATED_VIDEO_PROPS videoProps;
videoProps.width = 352;
videoProps.Height = 288;
videoProps.PixelAspectRatioX = 4;
videoProps.PixelAspectRatioY = 3;
videoProps.FrameDurationMiliSec; // 40 msec = 25 FPS
videoProps.NumberOfFrames = 1600; // 1600 frames
videoProps.VideoFormat = rzdcxLib::MPEG2_AT_MAIN_LEVEL;
obj->SetVideoStream(filename.c_str(), videoProps);
obj->TransferSyntax = rzdcxLib::TS_MPEG2_MAIN_PROFILE_AT_HIGH_LEVEL;
/// You don't have to create an element every time,
/// just initialize it.
char pn[]="John^Doe";
el->Init(rzdcxLib::PatientsName);
el->PutCStringPtr((int)pn);
obj->insertElement(el);
el->Init(rzdcxLib::patientID);
el->Value = "123765";
obj->insertElement(el);
el->Init(rzdcxLib::studyInstanceUID);
el->Value = id->CreateUID(UID_TYPE_STUDY);
obj->insertElement(el);
el->Init(rzdcxLib::seriesInstanceUID);
el->Value = id->CreateUID(UID_TYPE_SERIES);
obj->insertElement(el);
el->Init(rzdcxLib::sopInstanceUID);
el->Value = id->CreateUID(UID_TYPE_INSTANCE);
obj->insertElement(el);
el->Init(rzdcxLib::sopClassUid);
el->Value = "1.2.840.10008.5.1.4.1.1.77.1.4.1"; // Video Photographic Image Storage
obj->insertElement(el);
el->Init(rzdcxLib::NumberOfFrames);
el->Value = (short)1600;
obj->insertElement(el);
el->Init(rzdcxLib::FrameIncrementPointer);
el->Value = rzdcxLib::FrameTime;
obj->insertElement(el);
filename += ".dcm";
obj->saveFile(filename.c_str());
}
No comments:
Post a Comment