比尔云BierYun--阿里云最新优惠活动
阿里云优惠码丨阿里云代金券

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

artoolkit从读取摄像头改为读取视频文件或图像http://www.bieryun.com/2938.html

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

[cpp] view plain copy

  1. char            vconf[512] = “-device=QUICKTIME -movie=file:///E:/VSproject/multitest/multitest/1.mp4”;

一行代码,注释掉

[cpp] view plain copy

  1. vconf[0] = ‘\0’;

即可。

[cpp] view plain copy

  1. ARParam         cparam;
  2.     ARGViewport     viewport;
  3.     ARPattHandle   *arPattHandle;
  4.     char            vconf[512] = “-device=QUICKTIME -movie=file:///E:/VSproject/multitest/multitest/1.mp4”;
  5.     char            configName[512];
  6.     int             xsize, ysize;
  7.     AR_PIXEL_FORMAT pixFormat;
  8.     int             i;
  9.     configName[0] = ‘\0’;
  10.     //vconf[0] = ‘\0’;
  11.     for (i = 1; i < argc; i++) {
  12.         if (strncmp(argv[i], “-config=”, 8) == 0) {
  13.             strcpy_s(configName, &argv[i][8]);
  14.         }
  15.         else {
  16.             if (vconf[0] != ‘\0’) strcat_s(vconf, ” “);
  17.             strcat_s(vconf, argv[i]);
  18.         }
  19.     }
  20.     if (configName[0] == ‘\0’) strcpy_s(configName, CONFIG_NAME);
  21.     /* open the video path */
  22.     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 string usage notes Default value Avail.: (1) Unavail.: (2)
-device=QUICKTIME Select 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]1to1 Do not fit the movie to the window or buffer size, butinstead display it at its original size (1 to 1 scaling). -no1to1 4.3.0
-[no]fill Rather than fitting the movie into the window so that allthe 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. -nofill 4.3.0
-[no]stretch Rather than fitting the movie into the window so that allthe 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. -nostretch 4.3.0
-[no]loop Request that the movie loop continuously. Thisparameter 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. -loop 4.3.0
-[no]showcontroller Show 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.) -showcontroller 4.3.0
-[no]mute Set movie audio volume to 0. -nomute 4.3.0
-[no]pause Open movie in paused state. A call to arVideoCapStart()would be required to unpause the movie. -pause 4.3.0
-width=w Scale movie native frame to width w. Width of movie frame. 4.3.0
-height=h Scale movie native frame to height h. Height of movie frame. 4.3.0
-[no]fliph Flip movie frame horizontally. -nofliph 4.3.0
-[no]flipv Flip movie frame vertically. -noflipv 4.3.0
-pixelformat=cccc Ignored unless -offscreen is also passed, requests return ofmovie 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]singlebuffer Ignored unless -offscreen is also passed, use single buffering ofcaptured movie instead of triple-buffering. -nosinglebuffer 4.3.0

17/10/19更新:

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

[cpp] view plain copy

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

 

相关推荐

  • 暂无文章

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

强烈推荐

高性能SSD云服务器ECS抗攻击,高可用云数据库RDS