赞
踩
本文仅供技术交流。
linux上krpano的安装与注册
在linux上,用java执行krpano命令
我以krpano-1.19-pr10为例,不必无官网下载,在这里下: http://pan.baidu.com/s/1bppkEbd 上传到服务器解压就可以了(里面有注册码)。可是,在生成全景图时,会有水印,怎么解决呢?在解压的文件夹里,有个叫Serial.txt文件,是一个注册码。只需要在服务器注册这个注册码就行了,每个用户都注册一遍。
我先把krpano-1.19-pr10上传到/opt目录下,unrar 解压,然后执行krpanotools register命令注册机器:
root@S189919:/opt/krpano-1.19-pr10# /opt/krpano-1.19-pr10/krpanotools register FXsqTqaGNSZER5dSETEm+VzQEh9sWSa5DZMFsSmMxYV9GcXs8W3R8A/mWXrGNUceXvrihmh28hfRF1ivrW0HMzEychPvNiD8B/4/ZzDaUE9Rh6Ig22aKJGDbja1/kYIqmc/VKfItRE2RTSOIbIroxOtsz626NIpxWksAAifwhpNwuPXqDQpz2sRUMBzoPqZktpkItoSenN2mKd8Klfx7pOuB6CIK3e1CDXgyndqOt2mWybLZcU/wfJVAecfxk15ghiqrzaDsbqrdABDowg==
Code registered.
root@S189919:/opt/krpano-1.19-pr10# exit
exit
wen@S189919:~$ cd /opt/krpano-1.19-pr10/
wen@S189919:/opt/krpano-1.19-pr10$ /opt/krpano-1.19-pr10/krpanotools register FXsqTqaGNSZER5dSETEm+VzQEh9sWSa5DZMFsSmMxYV9GcXs8W3R8A/mWXrGNUceXvrihmh28hfRF1ivrW0HMzEychPvNiD8B/4/ZzDaUE9Rh6Ig22aKJGDbja1/kYIqmc/VKfItRE2RTSOIbIroxOtsz626NIpxWksAAifwhpNwuPXqDQpz2sRUMBzoPqZktpkItoSenN2mKd8Klfx7pOuB6CIK3e1CDXgyndqOt2mWybLZcU/wfJVAecfxk15ghiqrzaDsbqrdABDowg==
Code registered.
因为java本身是跨平台的第一语言,所以选择java,就等于成功了一半。但在linux上,用java的runtime.exec与在win上的调用命令不同,文件路径也不同,这是最需要注意的!
以/opt/test/test.jpg的图片为例
krpano在linux执行的命令是:
/opt/krpano-1.19-pr10/krpanotools makepano -config=templates/vtour-normal.config /opt/test/test.jpg
而win是:
cmd /c start f:\\krpano\\krpano-1.19-pr10-postable\\krpanotools32.exe makepano -config=\\templates\\vtour-normal.config f:\\test\\test.jpg
linux的文件目录是”/ “,win是”\\”。
这是完整的krpano工具类:CmdBat
package com.xforce.krpano.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class CmdBat {
/*public static void main(String[] args) {
String dpath = "D:\\apache-tomcat-8.0.33\\webapps\\krpano\\vshow";
String file = "353";
String[] fn1 = {};
String[] fn2 = {};
String title = "yyyyyyyy";
String temppath = "f:\\temp-room\\";
String music = "vshow/backgroundmusic/default.mp3";
try {
setKrpano(dpath, file,temppath, fn1, fn2, title,music);
} catch (InterruptedException e) {
e.printStackTrace();
System.out.println("上传失败");
}
}*/
public static void setKrpano(final String dpath, final String file,final String temppath,
final String[] fn1, final String[] fn2, final String title,final String music)
throws InterruptedException {
String path = temppath + file;
File targetFile = new File(path);
if(!targetFile.exists()){
targetFile.mkdirs();
}
String ex = "/opt/krpano-1.19-pr10/krpanotools makepano -config=templates/vtour-normal.config "
+ path + "/*.jpg";
Runtime runtime = Runtime.getRuntime();
String[] cmd = new String[]{
"/bin/sh","-c", ex };
boolean b = true;
Process p = null;
try {
p = runtime.exec(cmd);
} catch (Exception e) {
b = false;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。