当前位置: 首页 > 工具软件 > Artoolkit > 使用案例 >

artoolkit从读取摄像头改为读取视频文件或图像

丁阎宝
2023-12-01

artoolkit默认是读取摄像头的,但是由于需要,想读取视频文件。鼓捣了两天,最后发现只需修改

char            vconf[512] = "-device=QUICKTIME -movie=file:///E:/VSproject/multitest/multitest/1.mp4";
一行代码,注释掉
vconf[0] = '\0';
即可。

ARParam         cparam;
	ARGViewport     viewport;
	ARPattHandle   *arPattHandle;
	char            vconf[512] = "-device=QUICKTIME -movie=file:///E:/VSproject/multitest/multitest/1.mp4";
	char            configName[512];
	int             xsize, ysize;
	AR_PIXEL_FORMAT pixFormat;
	int             i;

	configName[0] = '\0';
	//vconf[0] = '\0';
	for (i = 1; i < argc; i++) {
		if (strncmp(argv[i], "-config=", 8) == 0) {
			strcpy_s(configName, &argv[i][8]);
		}
		else {
			if (vconf[0] != '\0') strcat_s(vconf, " ");
			strcat_s(vconf, argv[i]);
		}
	}
	if (configName[0] == '\0') strcpy_s(configName, CONFIG_NAME);

	/* open the video path */
	if (arVideoOpen(vconf) < 0) exit(0);

经测试.mp4/.mov都行,也能识别标记物,别的没测试过,有一种能播放就行。

改代码之前,先安装一个QuickTime player,然后可能会报错找不到QTCF.dll文件,这里解决http://ghoulrobert.lofter.com/post/177203_6d4de03

参考文献:http://www.artoolworks.com/support/library/Configuring_video_capture_in_ARToolKit_Professional

PS:看似简单,但是我这个菜鸟弄了两天啊。。。。

QuickTime video input from movie file or stream


video config stringusage notesDefault valueAvail.: (1)Unavail.: (2)
-device=QUICKTIMESelect this device for use. 4.3.0 
-movie=file:///path/to/file
-movie="file:///path/to/file"
Specifies that video should be acquired from a QuickTime movie resource.

This can be any valid movie resource that QuickTime can open, including files and streams. If a movie file is to be opened, supply a file URI specifying the full pathname. Pathnames must be URI-encoded, i.e. if the pathname contains spaces, these should be replaced with '+' characters. e.g. -movie="file:///C:/Program+Files/QuickTime/Sample.mov" or -movie=file:///Developer/Examples/WebKit/WebKitMoviePlugIn/sample.mov . If a movie stream is to be opened, it may be specified via an "http://", "rtsp://" or "ftp://" URL, or it can be referred to in a stream description file (a .sdp file). In ARToolKit versions 4.3.0 - 4.4.4, the maximum URL length was 255 characters. As of ARToolKit 4.5.0, this has been increased to 1023 characters.

 4.3.0 
-[no]1to1Do not fit the movie to the window or buffer size, but

instead display it at its original size (1 to 1 scaling).

-no1to14.3.0 
-[no]fillRather than fitting the movie into the window so that all

the movie is visible, scale it so that it completely fills the window or buffer. The movie's aspect ratio will be maintained, and this may result in some of the movie being clipped at the top and bottom or left and right.

-nofill4.3.0 
-[no]stretchRather than fitting the movie into the window so that all

the movie is visible, scale it so that it completely fills the window or buffer. The movie's aspect ratio will be stretched if necessary so that no pixels are clipped.

-nostretch4.3.0 
-[no]loopRequest that the movie loop continuously. This

parameter has no effect for streaming movies. Unless this parameter is specified, calls to arVideoQuickTimeMovieIdle() will return AR_E_EOF when the movie has finished playing.

-loop4.3.0 
-[no]showcontrollerShow the QuickTime movie controller in the frame.

(Unfortunately, the user will not be able to interact with the controller to pause and jog the movie.)

-showcontroller4.3.0 
-[no]muteSet movie audio volume to 0.-nomute4.3.0 
-[no]pauseOpen movie in paused state. A call to arVideoCapStart()

would be required to unpause the movie.

-pause4.3.0 
-width=wScale movie native frame to width w.Width of movie frame.4.3.0 
-height=hScale movie native frame to height h.Height of movie frame.4.3.0 
-[no]fliphFlip movie frame horizontally.-nofliph4.3.0 
-[no]flipvFlip movie frame vertically.-noflipv4.3.0 
-pixelformat=ccccIgnored unless -offscreen is also passed, requests return of

movie frames with pixels in format cccc, where cccc is either a numeric pixel format number or a valid 4-character-code for a pixel format. The following values are supported: 32, BGRA, RGBA, ABGR, 24, 24BG, 2vuy, yuvs. (See http://developer.apple.com/quicktime/icefloe/dispatch020.html.)

Depends on platform; default for Mac OS X is 32 (i.e. ARGB), default for Windows is BGRA.4.3.0 
-[no]singlebufferIgnored unless -offscreen is also passed, use single buffering of

captured movie instead of triple-buffering.

-nosinglebuffer4.3.0

17/10/19更新:

最近又需要读取图像,然后发现了如何读取图像。

char            vconf[512] = "-device=Image -image=E:/FFOutput/3.jpg -noloop";


 类似资料: