Page 1 of 1

Convert DPX image sequence to TGA image sequence

Posted: 2007-08-06T08:49:50-07:00
by fournij
Hi

I want to convert a DPX image sequence to a TGA image sequence with adding watermark (image logo), timecode that came from the DPX header, and annotations.

I already did a small function into a MFC C++ program that do the job. I'm calling the function for each sequence that I have to convert to TGA :

Code: Select all

					
string input, output, tc;
Image img, logoImg

logoImg.read(m_sLogoPath);

for(int j = 0; j <= inputFileList.GetUpperBound(); j++){

	input = inputFileList.GetAt(j);//DPX image - Source
	output = outputFileList.GetAt(j);//TGA image - Destination

	img.read(input);
	img.type(TrueColorMatteType);
	img.font("arial");
	img.fontPointsize(38);
	img.fillColor("white");
	img.boxColor("#00000072");
	img.annotate( "Shot #12345", "+310+50");

	img.boxColor("#00000000");
	tc = img.attribute("dpx:television.time.code");

	img.annotate(tc, positionTC);

	img.composite( logoImg, "+215+120", BumpmapCompositeOp);

	img.write(output);

}

But after a 5or 6 hours of conversion ( this function is called for each dpx image sequence that I have to convert... and I have many of them), my software crash in a middle of a sequence conversion


Is anybody have an idea of how to optimize it ? Is something wrong in my code ?

Thanks

Re: Convert DPX image sequence to TGA image sequence

Posted: 2007-08-12T22:13:41-07:00
by anthony
Sounds like you have a memory leak somewhere, and as the computer fills memory it starts swapping, and 'trashes', whcih slows it down. eventually even 'swap' disk space becomes fill and the program crashes.

Two suggestions. do image one at a time, or debug to track down the memory leak.

Re: Convert DPX image sequence to TGA image sequence

Posted: 2007-08-20T10:57:15-07:00
by fournij
Hi

Thanks for the reply

I'm pretty sure this is a memory leaks, it happend after about 150 000 conversions.

For your first suggestion, "Do image one at a time", this is not what I'm doing right now ?

Thanks

Re: Convert DPX image sequence to TGA image sequence

Posted: 2007-08-21T00:10:48-07:00
by anthony
An image is a single 'layer' or graphic. a sequence is multiple images whcih form either a stack or 'layers' (which is flattened) or an animation (which is a multi-image save to a file).

animations of videos usually use a very very large number of images, and this are usally processed one at a time for most IM operations. If that operaton does not clean up the memory requests (or structures) it used, it will leak.

Anything that assigns memory, should also have a 'free' or 'finish' type function as well.

Re: Convert DPX image sequence to TGA image sequence

Posted: 2007-08-21T07:00:16-07:00
by fournij
Thanks for the answer

In my case, my DPX image sequence and I process them one at the time (as you can see in my code) by using the for loop. But to clean up the memory, I don't see any function in image.h free or finish.

As you can see in my code I'm using the same object img for all conversions. Should I create a object img each conversion ?

Also I add an image logo as a watermark "logoImg" with the function "composite". Is it the good way to do that.

The input files are DPX files
The logo file is a TGA file
The output files are TGA file

Thanks

Re: Convert DPX image sequence to TGA image sequence

Posted: 2007-08-22T05:00:04-07:00
by fournij
The error I received from the Windows Application Error log is :

Faulting application prepare.exe, version 1.0.1.0, faulting module core_rl_magick_.dll, version 6.3.5.4, fault address 0x0006b836.

Re: Convert DPX image sequence to TGA image sequence

Posted: 2007-08-22T07:46:20-07:00
by fournij
I restarted my application and I checked the Windows Task Manager and the memory usage of my application growing up. If I clear the calls to imagemagick, there is no memory leak.

So I don't know if I'm using magick++ in the good way or if magick++ has a memory leak.

I don't see any function to clean the memory...

Any idea ?

Re: Convert DPX image sequence to TGA image sequence

Posted: 2007-08-22T21:30:15-07:00
by anthony
Prehaps you should report you last findings to the Bugs Forum.

There should be some way to completely clear all memory usage.

However some systems never really release memory unless the system starts giving them trouble. This can be the cause of what you see. But memory that is used then freed then reused should not cause more memory to be requested from the system.

It is difficult to say.

Re: Convert DPX image sequence to TGA image sequence

Posted: 2007-08-23T11:19:15-07:00
by fournij
Hi

I found what is the call is doing a memory leak.

this is the function "annotate". If I don't call this function, my memory stay at the same level during the entire process (over 150 000 conversions).

I will report the bug and again thanks for your time !!!

Jimmy