我正在尝试从我的Android设备中的IP摄像头(onvif)获取图像。 http://192.168.0.10/cgi-bin/snapshot.cgi?stream=1
<pre>
Uri.Builder builder = new Uri.Builder();
// http://192.168.137.10/cgi-bin/snapshot.cgi?stream=1
builder.scheme("http")
.authority("192.168.0.10")
.appendPath("cgi-bin")
.appendPath("snapshot.cgi")
.appendQueryParameter("stream","1");
;
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
String myUrl = builder.build().toString();
request.setURI(new URI(myUrl));
// public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(myUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
// return myBitmap;
} catch (IOException e) {
e.printStackTrace();
// return null;
}
</pre>
我在连接时收到超时错误。有没有其他方法可以从IP摄像机下载图像。