⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 duoppm2avi.cc

📁 torch tracking code, it is a good code
💻 CC
字号:
const char *help = "\progname: duoppm2avi.cc\n\code2html: This program makes a video from 2 sequence of ppm images.\n\version: Torch3 vision2.0, 2004-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageRgb.h"#include "ffmpegVideoFile.h"#include "rgbRawVideoFile.h"#include "DiskXFile.h"#include "FileListCmdOption.h"#include "CmdLine.h"using namespace Torch;void compose(int width, int height, unsigned char *pixmap1, unsigned char *pixmap2, unsigned char *imagecomposite){	unsigned char *test = imagecomposite;		for (int h=0;h<height;h++) 	{		for (int l=0;l<width*3;l++) 			*test++ = *pixmap1++;		for (int l=0;l<width*3;l++)			*test++ = *pixmap2++;	}}int main(int argc, char **argv){	int width;	int height;	bool verbose;	int fps;	int bitrate;	char *output_filename;	FileListCmdOption input_file_list1("filelist 1", "the first list of input files");	input_file_list1.isArgument(true);	FileListCmdOption input_file_list2("filelist 2", "the second list of input files");	input_file_list2.isArgument(true);	// Construct the command line  	CmdLine cmd;	cmd.setBOption("write log", false);	  	// Put the help line at the beginning  	cmd.info(help);  	cmd.addText("\nArguments:");	cmd.addCmdOption(&input_file_list1);	cmd.addCmdOption(&input_file_list2);  	cmd.addICmdArg("width", &width, "width");  	cmd.addICmdArg("height", &height, "height");  	cmd.addText("\nOptions:");  	cmd.addBCmdOption("-verbose", &verbose, false, "verbose");  	cmd.addICmdOption("-fps", &fps, 25, "verbose");  	cmd.addSCmdOption("-o", &output_filename, "output.avi", "verbose");  	cmd.addICmdOption("-bitrate", &bitrate, 1000000, "bitrate for encoding");	cmd.read(argc, argv);	if(input_file_list1.n_files != input_file_list2.n_files) 		error("List of files should have the same number of lines.");	int nframes = input_file_list1.n_files;	VideoFile *output = NULL;	output = new ffmpegVideoFile();	output->open(output_filename, "w");	output->setIOption("width", 2 * width);	output->setIOption("height", height);	output->setROption("framerate", fps);	output->setIOption("bitrate", bitrate);	Image *imagecomposite = new ImageRgb(2 * width, height);	Image *image1 = new ImageRgb(width, height);	Image *image2 = new ImageRgb(width, height);	for(int i = 0 ; i < nframes ; i++)	{   			//		image1->load(input_file_list1.file_names[i]);		if((image1->width != width) || (image1->height != height))		{			warning("error incorrect image size.");						delete image1;			delete image2;			delete imagecomposite;			delete output;			return 1;		}		 		//		image2->load(input_file_list2.file_names[i]);		if((image2->width != width) || (image2->height != height))		{			warning("error incorrect image size.");						delete image1;			delete image2;			delete imagecomposite;			delete output;			return 1;		}		//	    	if(verbose) print("r");			//		compose(width, height, image1->pixmap, image2->pixmap, imagecomposite->pixmap);		if(verbose) print("c");			//		output->write(imagecomposite->pixmap);		if(verbose) print("w");		real percent = 100.0 * (i+1) / nframes;		print("%03d%\r", (int) percent);	}	print("\n");		output->close();	delete output;	delete image1;	delete image2;	delete imagecomposite;	return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -