如何用PHP从ip摄像机中捕获图像
到目前为止,我有这个代码,从来没有停止加载 camera.php如何用PHP从ip摄像机中捕获图像,php,ip-camera,Php,Ip Camera,到目前为止,我有这个代码,从来没有停止加载 camera.php $img = 'http://userid:password@ipaddress/mjpgstreamreq/1/image.jpg'; header ('content-type: image/jpeg'); readfile( $img ); index.html <img src="camera.php" /> <!-- But this does not work --> 如果我在页面
$img = 'http://userid:password@ipaddress/mjpgstreamreq/1/image.jpg';
header ('content-type: image/jpeg');
readfile( $img );
index.html
<img src="camera.php" />
<!-- But this does not work -->
如果我在页面上有一个带有这个url的img标签,因为src也从未停止加载页面,我只是尝试读取快照,这不是一个连续帧,这是一张用ip摄像头拍摄的记录照片,我想读取并保存在一个文件中以备将来需要,我在localhost,ip摄像头在另一个网络中(如果有必要的话),因此我如何才能在不继续加载的情况下读取此内容。您使用
readfile()
请求的资源是一个图像,而不仅仅是一个图像。因此,readfile()
操作永远不会结束-它只会随着流的继续不断地吐出更多的图像
您需要实现代码以HTTP流的形式打开资源,从流中解析出一个JPEG,然后停止读取。这可能并不简单。尝试一下,但请记住更改ip cam上的用户名、密码、ip和端口
<img src="http://myServer.com/cam.php" width="640" height="380" name="refresh">
<script language="JavaScript" type="text/javascript">
image = "http://myServer.com/cam.php"
function Start() {
tmp = new Date();
tmp = "?"+tmp.getTime()
document.images["refresh"].src = image+tmp
setTimeout("Start()", 1000)
}
Start();
</script>
<?php
error_reporting(E_ALL);
$img="IPCAM_IP:PORT/snapshot.cgi?user=UserName&pwd=Password";
header ('content-type: image/jpeg');
readfile($img);
?>
图像=”http://myServer.com/cam.php"
函数Start(){
tmp=新日期();
tmp=“?”+tmp.getTime()
document.images[“刷新”].src=image+tmp
setTimeout(“Start()”,1000)
}
Start();
那么,人们知道他们在拍照吗?这背后的整个想法是我试图避免弹出询问登录信息的窗口,这样每个人都可以看到施工现场的最新图片,他们知道摄像机正在那里工作,我只想在一个网站上显示图像你可能应该使用PHP作为HTTP代理。我尝试使用github上一个人的一个PHP代理根本没有成功,这是github上代理的链接。你知道我如何设置一个循环来从这个mjpg获取jpg吗