`
mengdejun
  • 浏览: 412904 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

php高性能的缓存存储引擎secache 源代码

    博客分类:
  • Php
阅读更多
<?php
/**
 * secache 
 * 
 * @version $Id: secache.php 3 2009-02-14 15:00:41Z flaboy.cn $
 * @license MIT
 */
if(!defined('SECACHE_SIZE')){
    define('SECACHE_SIZE','1M');
}
class secache{

    var $idx_node_size = 40;
    var $data_base_pos = 262588; //40+20+24*16+16*16*16*16*4;
    var $schema_item_size = 24;
    var $header_padding = 20; //保留空间 放置php标记防止下载
    var $info_size = 20; //保留空间 4+16 maxsize|ver

    //40起 添加20字节保留区域
    var $idx_seq_pos = 40; //id 计数器节点地址
    var $dfile_cur_pos = 44; //id 计数器节点地址
    var $idx_free_pos = 48; //id 空闲链表入口地址

    var $idx_base_pos = 444; //40+20+24*16
    var $min_size = 10240; //10M最小值
    var $schema_struct = array('size','free','lru_head','lru_tail','hits','miss'); 
    var $ver = '$Rev: 3 $';
    var $name = '系统默认缓存(文件型)';

    function workat($file){

        $this->_file = $file.'.php';
        $this->_bsize_list = array(
            512=>10,
            3<<10=>10,
            8<<10=>10,
            20<<10=>4,
            30<<10=>2,
            50<<10=>2,
            80<<10=>2,
            96<<10=>2,
            128<<10=>2,
            224<<10=>2,
            256<<10=>2,
            512<<10=>1,
            1024<<10=>1,
        );

        $this->_node_struct = array(
            'next'=>array(0,'V'),
            'prev'=>array(4,'V'),
            'data'=>array(8,'V'),
            'size'=>array(12,'V'),
            'lru_right'=>array(16,'V'),
            'lru_left'=>array(20,'V'),
            'key'=>array(24,'H*'),
        );

        if(!file_exists($this->_file)){
            $this->create();
        }else{
            $this->_rs = fopen($this->_file,'rb+') or $this->trigger_error('Can\'t open the cachefile: '.realpath($this->_file),E_USER_ERROR);
            $this->_seek($this->header_padding);
            $info = unpack('V1max_size/a*ver',fread($this->_rs,$this->info_size));
            if($info['ver']!=$this->ver){
                $this->_format(true);
            }else{
                $this->max_size = $info['max_size'];
            }
        }

        $this->idx_node_base = $this->data_base_pos+$this->max_size;
        $this->_block_size_list = array_keys($this->_bsize_list);
        sort($this->_block_size_list);
        return true;
    }

    function create(){
        $this->_rs = fopen($this->_file,'wb+') or $this->trigger_error('Can\'t open the cachefile: '.realpath($this->_file),E_USER_ERROR);;
        fseek($this->_rs,0);
        fputs($this->_rs,'<'.'?php exit()?'.'>');
        return $this->_format();
    }

    function _puts($offset,$data){
        if($offset < $this->max_size*1.5){
            $this->_seek($offset);
            return fputs($this->_rs,$data);
        }else{
            $this->trigger_error('Offset over quota:'.$offset,E_USER_ERROR);
        }
    }

    function _seek($offset){
        return fseek($this->_rs,$offset);
    }

    function clear(){
        return $this->_format(true);
    }

    function fetch($key,&$return){

        if($this->lock(false)){
            $locked = true;
        }

        if($this->search($key,$offset)){
            $info = $this->_get_node($offset);
            $schema_id = $this->_get_size_schema_id($info['size']);
            if($schema_id===false){
                if($locked) $this->unlock();
                return false;
            }

            $this->_seek($info['data']);
            $data = fread($this->_rs,$info['size']);
            $return = unserialize($data);

            if($return===false){
                if($locked) $this->unlock();
                return false;
            }

            if($locked){
                $this->_lru_push($schema_id,$info['offset']);
                $this->_set_schema($schema_id,'hits',$this->_get_schema($schema_id,'hits')+1);
                return $this->unlock();
            }else{
                return true;
            }
        }else{
            if($locked) $this->unlock();
            return false;
        }
    }

    /**
     * lock 
     * 如果flock不管用,请继承本类,并重载此方法
     * 
     * @param mixed $is_block 是否阻塞
     * @access public
     * @return void
     */
    function lock($is_block,$whatever=false){
        return flock($this->_rs, $is_block?LOCK_EX:LOCK_EX+LOCK_NB);
    }

    /**
     * unlock 
     * 如果flock不管用,请继承本类,并重载此方法
     * 
     * @access public
     * @return void
     */   
    function unlock(){
        return flock($this->_rs, LOCK_UN);
    }

    function delete($key,$pos=false){
        if($pos || $this->search($key,$pos)){
            if($info = $this->_get_node($pos)){
                //删除data区域
                if($info['prev']){
                    $this->_set_node($info['prev'],'next',$info['next']);
                    $this->_set_node($info['next'],'prev',$info['prev']);
                }else{ //改入口位置
                    $this->_set_node($info['next'],'prev',0);
                    $this->_set_node_root($key,$info['next']);
                }
                $this->_free_dspace($info['size'],$info['data']);
                $this->_lru_delete($info);
                $this->_free_node($pos);
                return $info['prev'];
            }
        }
        return false;
    }

    function store($key,$value){

        if($this->lock(true)){
            //save data
            $data = serialize($value);
            $size = strlen($data);

            //get list_idx
            $has_key = $this->search($key,$list_idx_offset);
            $schema_id = $this->_get_size_schema_id($size);
            if($schema_id===false){
                $this->unlock();
                return false;
            }
            if($has_key){
                $hdseq = $list_idx_offset;

                $info = $this->_get_node($hdseq);
                if($schema_id == $this->_get_size_schema_id($info['size'])){
                    $dataoffset = $info['data'];
                }else{
                    //破掉原有lru
                    $this->_lru_delete($info);
                    if(!($dataoffset = $this->_dalloc($schema_id))){
                        $this->unlock();
                        return false;
                    }
                    $this->_free_dspace($info['size'],$info['data']);
                    $this->_set_node($hdseq,'lru_left',0);
                    $this->_set_node($hdseq,'lru_right',0);
                }

                $this->_set_node($hdseq,'size',$size);
                $this->_set_node($hdseq,'data',$dataoffset);
            }else{

                if(!($dataoffset = $this->_dalloc($schema_id))){
                    $this->unlock();
                    return false;
                }
                $hdseq = $this->_alloc_idx(array(
                    'next'=>0,
                    'prev'=>$list_idx_offset,
                    'data'=>$dataoffset,
                    'size'=>$size,
                    'lru_right'=>0,
                    'lru_left'=>0,
                    'key'=>$key,
                ));

                if($list_idx_offset>0){
                    $this->_set_node($list_idx_offset,'next',$hdseq);
                }else{
                    $this->_set_node_root($key,$hdseq);
                }
            }

            if($dataoffset>$this->max_size){
                $this->trigger_error('alloc datasize:'.$dataoffset,E_USER_WARNING);
                return false;
            }
            $this->_puts($dataoffset,$data);

            $this->_set_schema($schema_id,'miss',$this->_get_schema($schema_id,'miss')+1);

            $this->_lru_push($schema_id,$hdseq);
            $this->unlock();
            return true;
        }else{
            $this->trigger_error("Couldn't lock the file !",E_USER_WARNING);
            return false;
        }

    }

    /**
     * search 
     * 查找指定的key
     * 如果找到节点则$pos=节点本身 返回true
     * 否则 $pos=树的末端 返回false
     * 
     * @param mixed $key 
     * @access public
     * @return void
     */
    function search($key,&$pos){
        return $this->_get_pos_by_key($this->_get_node_root($key),$key,$pos);
    }

    function _get_size_schema_id($size){
        foreach($this->_block_size_list as $k=>$block_size){
            if($size <= $block_size){
                return $k;
            }
        }
        return false;
    }

    function _parse_str_size($str_size,$default){
        if(preg_match('/^([0-9]+)\s*([gmk]|)$/i',$str_size,$match)){
            switch(strtolower($match[2])){
            case 'g':
                if($match[1]>1){
                    $this->trigger_error('Max cache size 1G',E_USER_ERROR);
                }
                $size = $match[1]<<30;
                break;
            case 'm':
                $size = $match[1]<<20;
                break;
            case 'k':
                $size = $match[1]<<10;
                break;
            default:
                $size = $match[1];
            }
            if($size<=0){
                $this->trigger_error('Error cache size '.$this->max_size,E_USER_ERROR);
                return false;
            }elseif($size<10485760){
                return 10485760;
            }else{
                return $size;
            }
        }else{
            return $default;
        }
    }


    function _format($truncate=false){
        if($this->lock(true,true)){

            if($truncate){
                $this->_seek(0);
                ftruncate($this->_rs,$this->idx_node_base);
            }

            $this->max_size = $this->_parse_str_size(SECACHE_SIZE,15728640); //default:15m
            $this->_puts($this->header_padding,pack('V1a*',$this->max_size,$this->ver));

            ksort($this->_bsize_list);
            $ds_offset = $this->data_base_pos;
            $i=0;
            foreach($this->_bsize_list as $size=>$count){

                //将预分配的空间注册到free链表里
                $count *= min(3,floor($this->max_size/10485760));
                $next_free_node = 0;
                for($j=0;$j<$count;$j++){
                    $this->_puts($ds_offset,pack('V',$next_free_node));
                    $next_free_node = $ds_offset;
                    $ds_offset+=intval($size);
                }

                $code = pack(str_repeat('V1',count($this->schema_struct)),$size,$next_free_node,0,0,0,0);

                $this->_puts(60+$i*$this->schema_item_size,$code);
                $i++;
            }
            $this->_set_dcur_pos($ds_offset);

            $this->_puts($this->idx_base_pos,str_repeat("\0",262144));
            $this->_puts($this->idx_seq_pos,pack('V',1));
            $this->unlock();
            return true;
        }else{
            $this->trigger_error("Couldn't lock the file !",E_USER_ERROR);
            return false;
        }
    }

    function _get_node_root($key){
        $this->_seek(hexdec(substr($key,0,4))*4+$this->idx_base_pos);
        $a= fread($this->_rs,4);
        list(,$offset) = unpack('V',$a);
        return $offset;
    }

    function _set_node_root($key,$value){
        return $this->_puts(hexdec(substr($key,0,4))*4+$this->idx_base_pos,pack('V',$value));
    }

    function _set_node($pos,$key,$value){

        if(!$pos){
            return false;
        }

        if(isset($this->_node_struct[$key])){
            return $this->_puts($pos*$this->idx_node_size+$this->idx_node_base+$this->_node_struct[$key][0],pack($this->_node_struct[$key][1],$value));
        }else{
            return false;
        }
    }

    function _get_pos_by_key($offset,$key,&$pos){
        if(!$offset){
            $pos = 0;
            return false;
        }

        $info = $this->_get_node($offset);

        if($info['key']==$key){
            $pos = $info['offset'];
            return true;
        }elseif($info['next'] && $info['next']!=$offset){
            return $this->_get_pos_by_key($info['next'],$key,$pos);
        }else{
            $pos = $offset;
            return false;
        }
    }

    function _lru_delete($info){

        if($info['lru_right']){
            $this->_set_node($info['lru_right'],'lru_left',$info['lru_left']);
        }else{
            $this->_set_schema($this->_get_size_schema_id($info['size']),'lru_tail',$info['lru_left']);
        }

        if($info['lru_left']){
            $this->_set_node($info['lru_left'],'lru_right',$info['lru_right']);
        }else{
            $this->_set_schema($this->_get_size_schema_id($info['size']),'lru_head',$info['lru_right']);
        }

        return true;
    }

    function _lru_push($schema_id,$offset){
        $lru_head = $this->_get_schema($schema_id,'lru_head');
        $lru_tail = $this->_get_schema($schema_id,'lru_tail');

        if((!$offset) || ($lru_head==$offset))return;

        $info = $this->_get_node($offset);

        $this->_set_node($info['lru_right'],'lru_left',$info['lru_left']);
        $this->_set_node($info['lru_left'],'lru_right',$info['lru_right']);

        $this->_set_node($offset,'lru_right',$lru_head);
        $this->_set_node($offset,'lru_left',0);

        $this->_set_node($lru_head,'lru_left',$offset);
        $this->_set_schema($schema_id,'lru_head',$offset);

        if($lru_tail==0){
            $this->_set_schema($schema_id,'lru_tail',$offset);
        }elseif($lru_tail==$offset && $info['lru_left']){
            $this->_set_schema($schema_id,'lru_tail',$info['lru_left']);
        }
        return true;
    }

    function _get_node($offset){
        $this->_seek($offset*$this->idx_node_size + $this->idx_node_base);
        $info = unpack('V1next/V1prev/V1data/V1size/V1lru_right/V1lru_left/H*key',fread($this->_rs,$this->idx_node_size));
        $info['offset'] = $offset;
        return $info;
    }

    function _lru_pop($schema_id){
        if($node = $this->_get_schema($schema_id,'lru_tail')){
            $info = $this->_get_node($node);
            if(!$info['data']){
                return false;
            }
            $this->delete($info['key'],$info['offset']);
            if(!$this->_get_schema($schema_id,'free')){
                $this->trigger_error('pop lru,But nothing free...',E_USER_ERROR);
            }
            return $info;
        }else{
            return false;
        }
    }

    function _dalloc($schema_id,$lru_freed=false){

        if($free = $this->_get_schema($schema_id,'free')){ //如果lru里有链表
            $this->_seek($free);
            list(,$next) = unpack('V',fread($this->_rs,4));
            $this->_set_schema($schema_id,'free',$next);
            return $free;
        }elseif($lru_freed){
            $this->trigger_error('Bat lru poped freesize',E_USER_ERROR);
            return false;
        }else{
            $ds_offset = $this->_get_dcur_pos();
            $size = $this->_get_schema($schema_id,'size');

            if($size+$ds_offset > $this->max_size){
                if($info = $this->_lru_pop($schema_id)){
                    return $this->_dalloc($schema_id,$info);
                }else{
                    $this->trigger_error('Can\'t alloc dataspace',E_USER_ERROR);
                    return false;
                }
            }else{
                $this->_set_dcur_pos($ds_offset+$size);
                return $ds_offset;
            }
        }
    }

    function _get_dcur_pos(){
        $this->_seek($this->dfile_cur_pos);
        list(,$ds_offset) = unpack('V',fread($this->_rs,4));
        return $ds_offset;
    }
    function _set_dcur_pos($pos){
        return $this->_puts($this->dfile_cur_pos,pack('V',$pos));
    }

    function _free_dspace($size,$pos){

        if($pos>$this->max_size){
            $this->trigger_error('free dspace over quota:'.$pos,E_USER_ERROR);
            return false;
        }

        $schema_id = $this->_get_size_schema_id($size);
        if($free = $this->_get_schema($schema_id,'free')){
            $this->_puts($free,pack('V1',$pos));
        }else{
            $this->_set_schema($schema_id,'free',$pos);
        }
        $this->_puts($pos,pack('V1',0));
    }

    function _dfollow($pos,&$c){
        $c++;
        $this->_seek($pos);
        list(,$next) = unpack('V1',fread($this->_rs,4));
        if($next){
            return $this->_dfollow($next,$c);
        }else{
            return $pos;
        }
    }

    function _free_node($pos){
        $this->_seek($this->idx_free_pos);
        list(,$prev_free_node) = unpack('V',fread($this->_rs,4));
        $this->_puts($pos*$this->idx_node_size+$this->idx_node_base,pack('V',$prev_free_node).str_repeat("\0",$this->idx_node_size-4));
        return $this->_puts($this->idx_free_pos,pack('V',$pos));
    }

    function _alloc_idx($data){
        $this->_seek($this->idx_free_pos);
        list(,$list_pos) = unpack('V',fread($this->_rs,4));
        if($list_pos){

            $this->_seek($list_pos*$this->idx_node_size+$this->idx_node_base);
            list(,$prev_free_node) = unpack('V',fread($this->_rs,4));
            $this->_puts($this->idx_free_pos,pack('V',$prev_free_node));

        }else{
            $this->_seek($this->idx_seq_pos);
            list(,$list_pos) = unpack('V',fread($this->_rs,4));
            $this->_puts($this->idx_seq_pos,pack('V',$list_pos+1));
        }
        return $this->_create_node($list_pos,$data);
    }

    function _create_node($pos,$data){
        $this->_puts($pos*$this->idx_node_size + $this->idx_node_base
            ,pack('V1V1V1V1V1V1H*',$data['next'],$data['prev'],$data['data'],$data['size'],$data['lru_right'],$data['lru_left'],$data['key']));
        return $pos;
    }

    function _set_schema($schema_id,$key,$value){
        $info = array_flip($this->schema_struct);
        return $this->_puts(60+$schema_id*$this->schema_item_size + $info[$key]*4,pack('V',$value));
    }

    function _get_schema($id,$key){
        $info = array_flip($this->schema_struct);

        $this->_seek(60+$id*$this->schema_item_size);
        unpack('V1'.implode('/V1',$this->schema_struct),fread($this->_rs,$this->schema_item_size));

        $this->_seek(60+$id*$this->schema_item_size + $info[$key]*4);
        list(,$value) =unpack('V',fread($this->_rs,4));
        return $value;
    }

    function _all_schemas(){
        $schema = array();
        for($i=0;$i<16;$i++){
            $this->_seek(60+$i*$this->schema_item_size);
            $info = unpack('V1'.implode('/V1',$this->schema_struct),fread($this->_rs,$this->schema_item_size));
            if($info['size']){
                $info['id'] = $i;
                $schema[$i] = $info;
            }else{
                return $schema;
            }
        }
    }

    function schemaStatus(){
        $return = array();
        foreach($this->_all_schemas() as $k=>$schemaItem){
            if($schemaItem['free']){
                $this->_dfollow($schemaItem['free'],$schemaItem['freecount']);
            }
            $return[] = $schemaItem;
        }
        return $return;
    }

    function status(&$curBytes,&$totalBytes){
        $totalBytes = $curBytes = 0;
        $hits = $miss = 0;

        $schemaStatus = $this->schemaStatus();
        $totalBytes = $this->max_size;
        $freeBytes = $this->max_size - $this->_get_dcur_pos();

        foreach($schemaStatus as $schema){
            $freeBytes+=$schema['freecount']*$schema['size'];
            $miss += $schema['miss'];
            $hits += $schema['hits'];
        }
        $curBytes = $totalBytes-$freeBytes;

        $return[] = array('name'=>'缓存命中','value'=>$hits);
        $return[] = array('name'=>'缓存未命中','value'=>$miss);
        return $return;
    }

    function trigger_error($errstr,$errno){
        trigger_error($errstr,$errno);
    }

}
?>

 

<?php
require(dir(__FILE__).'/secache.php');
class secache_no_flock extends secache{

    function secache_no_flock(){
        parent::secache();
        $this->__support_usleep = version_compare(PHP_VERSION,5,'>=')?20:1;
    }

    function lock($is_block,$whatever=false){

        ignore_user_abort(1);
        $lockfile = $this->_file . '.lck';

        if (file_exists($lockfile)) {
            if (time() - filemtime($lockfile) > 5){
               unlink($lockfile);
            }elseif(!$is_block){
                return false;
            }
        }

        $lock_ex = @fopen($lockfile, 'x');
        for ($i=0; ($lock_ex === false) && ($whatever || $i < 20); $i++) {
           clearstatcache();
           if($this->__support_usleep==1){
               usleep(rand(9, 999));
           }else{
               sleep(1);
           }
           $lock_ex = @fopen($lockfile, 'x');
        }

        return ($lock_ex !== false);
    }

    function unlock(){
        ignore_user_abort(0);
        return unlink($this->_file.'.lck');
    }
}
?>

 

  

  • 纯php实现, 无须任何扩展,支持php4 / 5
  • 使用lru算法自动清理过期内容
  • 可以安全用于多进程并发
  • 最大支持1G缓存文件
  • 使用hash定位,读取迅速
  • 下载地址:http://code.google.com/p/secache/

     

    分享到:
    评论

    相关推荐

      secachePHP文件缓存

      **secachePHP文件缓存**是一种轻量级的文件存储解决方案,特别适用于PHP开发者,它提供了高效的缓存机制,能够显著提升网站或应用程序的性能。相比直接操作文件系统进行读写,secache优化了文件缓存的过程,提高了...

      PHP文件缓存

      PHP文件缓存的主要功能页面,主要是根据一个键值直接计算出文件目录,从而减少查找文件的时间。

      NTFS Links 1.1.2 创建软链接软件 使用说明

      将搜狗浏览器缓存文件夹剪切到新建的目标文件夹中(如E盘的“SECache”文件夹)。 5. 最后,使用NTFS Links 1.1.2软件在原路径创建指向新位置的软链接,完成缓存目录的转移。 #### 四、总结 **NTFS Links 1.1.2*...

      智能车竞赛介绍(竞赛目标和赛程安排).zip

      全国大学生智能汽车竞赛自2006年起,由教育部高等教育司委托高等学校自动化类教学指导委员会举办,旨在加强学生实践、创新能力和培养团队精神的一项创意性科技竞赛。该竞赛至今已成功举办多届,吸引了众多高校学生的积极参与,此文件为智能车竞赛介绍

      集字卡v4.3.4微信公众号原版三种UI+关键字卡控制+支持强制关注.zip

      字卡v4.3.4 原版 三种UI+关键字卡控制+支持获取用户信息+支持强制关注 集卡模块从一开始的版本到助力版本再到现在的新规则版本。 集卡模块难度主要在于 如何控制各种不同的字卡组合 被粉丝集齐的数量。 如果不控制那么一定会出现超过数量的粉丝集到指定的字卡组合,造成奖品不够的混乱,如果大奖价值高的话,超过数量的粉丝集到大奖后,就造成商家的活动费用超支了。我们冥思苦想如何才能限制集到指定字卡组合的粉丝数,后我们想到了和支付宝一样的选一张关键字卡来进行规则设置的方式来进行限制,根据奖品所需的关键字卡数,设定规则就可以控制每种奖品所需字卡组合被粉丝集到的数量,规则可以在活动进行中根据需要进行修改,活动规则灵活度高。新版的集卡规则,在此次政府发布号的活动中经受了考验,集到指定字卡组合的粉丝没有超出规则限制。有了这个规则限制后,您无需盯着活动,建好活动后就无人值守让活动进行就行了,您只需要时不时来看下蹭蹭上涨的活动数据即可。 被封? 无需担心,模块内置有防封功能,支持隐藏主域名,显示炮灰域名,保护活动安全进行。 活动准备? 只需要您有一个认证服务号即可,支持订阅号借用认证服务号来做活动。如果您

      出口设备线体程序详解:PLC通讯下的V90控制与开源FB284工艺对象实战指南,出口设备线体程序详解:PLC通讯与V90控制集成,工艺对象与FB284协同工作,开源学习V90控制技能,出口设备1200

      出口设备线体程序详解:PLC通讯下的V90控制与开源FB284工艺对象实战指南,出口设备线体程序详解:PLC通讯与V90控制集成,工艺对象与FB284协同工作,开源学习V90控制技能,出口设备1200线体程序,多个plc走通讯,内部有多个v90,采用工艺对象与fb284 共同控制,功能快全部开源,能快速学会v90的控制 ,出口设备; 1200线体程序; PLC通讯; 多个V90; 工艺对象; FB284; 功能开源; V90控制。,V90工艺控制:开源功能快,快速掌握1200线体程序与PLC通讯

      基于Arduino与DAC8031的心电信号模拟器资料:心电信号与正弦波的双重输出应用方案,Arduino与DAC8031心电信号模拟器:生成心电信号与正弦波输出功能详解,基于arduino +DAC

      基于Arduino与DAC8031的心电信号模拟器资料:心电信号与正弦波的双重输出应用方案,Arduino与DAC8031心电信号模拟器:生成心电信号与正弦波输出功能详解,基于arduino +DAC8031的心电信号模拟器资料,可输出心电信号,和正弦波 ,基于Arduino;DAC8031;心电信号模拟器;输出心电信号;正弦波输出;模拟器资料,基于Arduino与DAC8031的心电信号模拟器:输出心电与正弦波

      (参考项目)MATLAB口罩识别检测.zip

      MATLAB口罩检测的基本流程 图像采集:通过摄像头或其他图像采集设备获取包含面部的图像。 图像预处理:对采集到的图像进行灰度化、去噪、直方图均衡化等预处理操作,以提高图像质量,便于后续的人脸检测和口罩检测。 人脸检测:利用Haar特征、LBP特征等经典方法或深度学习模型(如MTCNN、FaceBoxes等)在预处理后的图像中定位人脸区域。 口罩检测:在检测到的人脸区域内,进一步分析是否佩戴口罩。这可以通过检测口罩的边缘、纹理等特征,或使用已经训练好的口罩检测模型来实现。 结果输出:将检测结果以可视化方式展示,如在图像上标注人脸和口罩区域,或输出文字提示是否佩戴口罩。

      kernel-debug-devel-3.10.0-1160.119.1.el7.x64-86.rpm.tar.gz

      1、文件内容:kernel-debug-devel-3.10.0-1160.119.1.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/kernel-debug-devel-3.10.0-1160.119.1.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、更多资源/技术支持:公众号禅静编程坊

      day02供应链管理系统-补充.zip

      该文档提供了一个关于供应链管理系统开发的详细指南,重点介绍了项目安排、技术实现和框架搭建的相关内容。 文档分为以下几个关键部分: 项目安排:主要步骤包括搭建框架(1天),基础数据模块和权限管理(4天),以及应收应付和销售管理(5天)。 供应链概念:供应链系统的核心流程是通过采购商品放入仓库,并在销售时从仓库提取商品,涉及三个主要订单:采购订单、销售订单和调拨订单。 大数据的应用:介绍了数据挖掘、ETL(数据抽取)和BI(商业智能)在供应链管理中的应用。 技术实现:讲述了DAO(数据访问对象)的重用、服务层的重用、以及前端JS的继承机制、jQuery插件开发等技术细节。 系统框架搭建:包括Maven环境的配置、Web工程的创建、持久化类和映射文件的编写,以及Spring配置文件的实现。 DAO的需求和功能:供应链管理系统的各个模块都涉及分页查询、条件查询、删除、增加、修改操作等需求。 泛型的应用:通过示例说明了在Java语言中如何使用泛型来实现模块化和可扩展性。 文档非常技术导向,适合开发人员参考,用于构建供应链管理系统的架构和功能模块。

      基于四旋翼无人机的PD控制研究 附Matlab代码.rar

      1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。

      C#与VB实现欧姆龙PLC的Fins TCP通信案例源码:调用动态链接库进行数据读写,定时器与计数器数据区的简洁读写操作示例,C#与VB实现欧姆龙PLC的Fins TCP通信案例源码:调用动态链接库进

      C#与VB实现欧姆龙PLC的Fins TCP通信案例源码:调用动态链接库进行数据读写,定时器与计数器数据区的简洁读写操作示例,C#与VB实现欧姆龙PLC的Fins TCP通信案例源码:调用动态链接库进行读写操作,涵盖定时器计数器数据区学习案例,C#欧姆龙plc Fins Tcp通信案例上位机源码,有c#和VB的Demo,c#上位机和欧姆龙plc通讯案例源码,调用动态链接库,可以实现上位机的数据连接,可以简单实现D区W区定时器计数器等数据区的读写,是一个非常好的学习案例 ,C#; 欧姆龙PLC; Fins Tcp通信; 上位机源码; 动态链接库; 数据连接; D区W区读写; 定时器计数器; 学习案例,C#实现欧姆龙PLC Fins Tcp通信上位机源码,读写数据区高效学习案例

      可调谐石墨烯超材料吸收体的FDTD仿真模拟研究报告:吸收光谱的化学势调节策略与仿真源文件解析,可调谐石墨烯超材料吸收体:化学势调节光谱的FDTD仿真模拟研究,可调谐石墨烯超材料吸收体FDTD仿真模拟

      可调谐石墨烯超材料吸收体的FDTD仿真模拟研究报告:吸收光谱的化学势调节策略与仿真源文件解析,可调谐石墨烯超材料吸收体:化学势调节光谱的FDTD仿真模拟研究,可调谐石墨烯超材料吸收体FDTD仿真模拟 【案例内容】该案例提供了一种可调谐石墨烯超材料吸收体,其吸收光谱可以通过改变施加于石墨烯的化学势来进行调节。 【案例文件】仿真源文件 ,可调谐石墨烯超材料吸收体; FDTD仿真模拟; 化学势调节; 仿真源文件,石墨烯超材料吸收体:FDTD仿真调节吸收光谱案例解析

      RBF神经网络控制仿真-第二版

      RBF神经网络控制仿真-第二版

      松下PLC与威纶通触摸屏转盘设备控制:FPWINPRO7与EBPRO智能编程与宏指令应用,松下PLC与威纶通触摸屏转盘设备控制解决方案:FPWINPRO7与EBPRO协同工作,实现多工位转盘加工与IE

      松下PLC与威纶通触摸屏转盘设备控制:FPWINPRO7与EBPRO智能编程与宏指令应用,松下PLC与威纶通触摸屏转盘设备控制解决方案:FPWINPRO7与EBPRO协同工作,实现多工位转盘加工与IEC编程模式控制,松下PLC+威纶通触摸屏的转盘设备 松下PLC工程使用程序版本为FPWINPRO7 7.6.0.0版本 威纶通HMI工程使用程序版本为EBPRO 6.07.02.410S 1.多工位转盘加工控制。 2.国际标准IEC编程模式。 3.触摸屏宏指令应用控制。 ,松下PLC; 威纶通触摸屏; 转盘设备控制; 多工位加工控制; IEC编程模式; 触摸屏宏指令应用,松下PLC与威纶通HMI联控的转盘设备控制程序解析

      基于循环神经网络(RNN)的多输入单输出预测模型(适用于时间序列预测与回归分析,需Matlab 2021及以上版本),基于循环神经网络(RNN)的多输入单输出预测模型(matlab版本2021+),真

      基于循环神经网络(RNN)的多输入单输出预测模型(适用于时间序列预测与回归分析,需Matlab 2021及以上版本),基于循环神经网络(RNN)的多输入单输出预测模型(matlab版本2021+),真实值与预测值对比,多种评价指标与线性拟合展示。,RNN预测模型做多输入单输出预测模型,直接替数据就可以用。 程序语言是matlab,需求最低版本为2021及以上。 程序可以出真实值和预测值对比图,线性拟合图,可打印多种评价指标。 PS:以下效果图为测试数据的效果图,主要目的是为了显示程序运行可以出的结果图,具体预测效果以个人的具体数据为准。 2.由于每个人的数据都是独一无二的,因此无法做到可以任何人的数据直接替就可以得到自己满意的效果。 这段程序主要是一个基于循环神经网络(RNN)的预测模型。它的应用领域可以是时间序列预测、回归分析等。下面我将对程序的运行过程进行详细解释和分析。 首先,程序开始时清空环境变量、关闭图窗、清空变量和命令行。然后,通过xlsread函数导入数据,其中'数据的输入'和'数据的输出'是两个Excel文件的文件名。 接下来,程序对数据进行归一化处理。首先使用ma

      【图像识别】手写文字识别研究 附Matlab代码+运行结果.rar

      1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。

      旅游管理系统(基于springboot,mysql,java).zip

      旅游管理系统中的功能模块主要是实现管理员;首页、个人中心、用户管理、旅游方案管理、旅游购买管理、系统管理,用户;首页、个人中心、旅游方案管理、旅游购买管理、我的收藏管理。前台首页;首页、旅游方案、旅游资讯、个人中心、后台管理等功能。经过认真细致的研究,精心准备和规划,最后测试成功,系统可以正常使用。分析功能调整与旅游管理系统实现的实际需求相结合,讨论了Java开发旅游管理系统的使用。 从上面的描述中可以基本可以实现软件的功能: 1、开发实现旅游管理系统的整个系统程序;  2、管理员;首页、个人中心、用户管理、旅游方案管理、旅游购买管理、系统管理等。 3、用户:首页、个人中心、旅游方案管理、旅游购买管理、我的收藏管理。 4、前台首页:首页、旅游方案、旅游资讯、个人中心、后台管理等相应操作; 5、基础数据管理:实现系统基本信息的添加、修改及删除等操作,并且根据需求进行交流查看及回复相应操作。

      Boost二级升压光伏并网结构的Simulink建模与MPPT最大功率点追踪:基于功率反馈的扰动观察法调整电压方向研究,Boost二级升压光伏并网结构的Simulink建模与MPPT最大功率点追踪:基

      Boost二级升压光伏并网结构的Simulink建模与MPPT最大功率点追踪:基于功率反馈的扰动观察法调整电压方向研究,Boost二级升压光伏并网结构的Simulink建模与MPPT最大功率点追踪:基于功率反馈的扰动观察法调整电压方向研究,Boost二级升压光伏并网结构,Simulink建模,MPPT最大功率点追踪,扰动观察法采用功率反馈方式,若ΔP>0,说明电压调整的方向正确,可以继续按原方向进行“干扰”;若ΔP<0,说明电压调整的方向错误,需要对“干扰”的方向进行改变。 ,Boost升压;光伏并网结构;Simulink建模;MPPT最大功率点追踪;扰动观察法;功率反馈;电压调整方向。,光伏并网结构中Boost升压MPPT控制策略的Simulink建模与功率反馈扰动观察法

      基于matlab平台的图像去雾设计.zip

      运行GUI版本,可二开

    Global site tag (gtag.js) - Google Analytics