$conf, $time;
$_uid = user_token_get_do();
empty($_uid) and user_token_clear(); // 退出登录
return $_uid;
}
// 用户
function user_token_get_do()
{
global $conf, $time, $ip, $useragent;
$token = param($conf['cookie_pre'] . 'token');
if (empty($token)) return FALSE;
$tokenkey = md5(xn_key());
$s = xn_decrypt($token, $tokenkey);
if (empty($s)) return FALSE;
$arr = explode("\t", $s);
if (count($arr) != 5) return FALSE;
list($_ip, $_time, $_uid, $_pwd, $ua_md5) = $arr;
if (array_value($conf, 'login_ip') && $ip != $_ip) return FALSE;
if (array_value($conf, 'login_ua') && md5($useragent) != $ua_md5) return FALSE;
$_user = user_read($_uid);
if (empty($_user)) return FALSE;
if (array_value($conf, 'login_only') && $_user['login_date'] != $_time) return FALSE;
// 密码是否被修改
if (md5($_user['password']) != $_pwd) return FALSE;
return $_uid;
}
// 设置 token,防止 sid 过期后被删除
function user_token_set($uid)
{
global $conf, $time;
if (empty($uid)) return '';
$token = user_token_gen($uid);
setcookie($conf['cookie_pre'] . 'token', $token, $time + 86400000, $conf['cookie_path'], $conf['cookie_domain'], '', TRUE);
return $token;
}
function user_token_clear()
{
global $conf, $time;
setcookie($conf['cookie_pre'] . 'token', '', $time - 8640000, $conf['cookie_path'], $conf['cookie_domain'], '', TRUE);
}
function user_token_gen($uid)
{
global $conf, $time, $ip, $useragent;
$key = 'user_token' . $uid;
static $cache = array();
if (isset($cache[$key])) return $cache[$key];
$user = user_read($uid);
$pwd = md5($user['password']);
$ua_md5 = md5($useragent);
$tokenkey = md5(xn_key());
$cache[$key] = xn_encrypt("$ip $time $uid $pwd $ua_md5", $tokenkey);
return $cache[$key];
}
// 前台登录验证
function user_login_check()
{
global $user;
empty($user) and http_location(url('user-login'));
}
// 获取用户来路
function user_http_referer()
{
global $conf;
$referer = param('referer'); // 优先从参数获取 | GET is priority
empty($referer) and $referer = array_value($_SERVER, 'HTTP_REFERER', '');
$referer = str_replace(array('\"', '"', '<', '>', ' ', '*', "\t", "\r", "\n"), '', $referer); // 干掉特殊字符 strip special chars
if (
!preg_match('#^(http|https)://[\w\-=/\.]+/[\w\-=.%\#?]*$#is', $referer)
|| FALSE !== strpos($referer, url('user-login'))
|| FALSE !== strpos($referer, url('user-logout'))
|| FALSE !== strpos($referer, url('user-create'))
|| FALSE !== strpos($referer, url('user-setpw'))
|| FALSE !== strpos($referer, url('user-resetpw_complete'))
) {
$referer = $conf['path'];
}
return $referer;
}
function user_auth_check($token)
{
global $time, $ip;
$auth = param(2);
$s = xn_decrypt($auth);
empty($s) and message(-1, lang('decrypt_failed'));
$arr = explode('-', $s);
count($arr) != 4 and message(-1, lang('encrypt_failed'));
list($_ip, $_time, $_uid, $_pwd) = $arr;
$_user = user_read($_uid);
empty($_user) and message(-1, lang('user_not_exists'));
$time - $_time > 3600 and message(-1, lang('link_has_expired'));
return $_user;
}
?>
机器视觉系统的构成-阿南达文事网
机器视觉系统的构成
编程日记80
更新时间:2025-05-10 18:57:44
机器视觉系统的构成
计算机视觉系统的构成主要包括光源、工业相机与工业镜头、传感器、图像采集卡、PC平台和视觉处理软件部分,具体功能如下:
光源
①光源——作为辅助成像器件,对成像质量好坏起到至关重要的作用,各种形状的LED灯、高频荧光灯、光纤卤素灯等都是常用光源。
工业相机与工业镜头
②工业相机与工业镜头——属于成像器件,通常视觉系统都是由一套或者多套成像系统组成,如果有多路相机,可能由图像卡切换来获取图像数据,也可能由同步控制同时获取多相机通道的数据。根据应用的需要相机可能是输出标准的单色视频(RS-170/CCIR)、复合信号(Y/C)、RGB信号,也可能是非标准的逐行扫描信号、线扫描信号、高分辨率信号等。
传感器
本文发布于:2023-12-06,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:机器视觉系统的构成
发布评论