-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path教女友学会python+yolov3调用笔记本摄像头——实时进行识别.html
800 lines (583 loc) · 31.1 KB
/
教女友学会python+yolov3调用笔记本摄像头——实时进行识别.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="keywords" content="python,matlab,yolo,yolov3,java,go,c++,c#" />
<meta name="description" content="孙全胜의Space" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>
教女友学会python+yolov3调用笔记本摄像头——实时进行识别 | 孙全胜의Space
</title>
<meta name="generator" content="hexo-theme-ayer">
<link rel="shortcut icon" href="/bitbug_favicon.ico" />
<link rel="stylesheet" href="/dist/main.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">
<link rel="stylesheet" href="/css/custom.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/pace.min.js"></script>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-168079169-1', 'auto');
ga('send', 'pageview');
</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?6101cdb197f4b6300cb90fa7e51accec";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<link rel="alternate" href="/atom.xml" title="孙全胜의Space" type="application/atom+xml">
</head>
</html>
<body>
<canvas width="1777" height="841" style="position: fixed; left: 0px; top: 0px; z-index: 999; pointer-events: none;"></canvas>
<div id="app">
<main class="content on">
<section class="outer">
<article id="post-教女友学会python+yolov3调用笔记本摄像头——实时进行识别" class="article article-type-post" itemscope
itemprop="blogPost" data-scroll-reveal>
<div class="article-inner">
<header class="article-header">
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
教女友学会python+yolov3调用笔记本摄像头——实时进行识别
</h1>
</header>
<div class="article-meta">
<a href="/%E6%95%99%E5%A5%B3%E5%8F%8B%E5%AD%A6%E4%BC%9Apython+yolov3%E8%B0%83%E7%94%A8%E7%AC%94%E8%AE%B0%E6%9C%AC%E6%91%84%E5%83%8F%E5%A4%B4%E2%80%94%E2%80%94%E5%AE%9E%E6%97%B6%E8%BF%9B%E8%A1%8C%E8%AF%86%E5%88%AB.html" class="article-date">
<time datetime="2020-06-17T11:37:19.000Z" itemprop="datePublished">2020-06-17</time>
</a>
<div class="article-category">
<a class="article-category-link" href="/categories/python/">python</a> / <a class="article-category-link" href="/categories/python/%E6%9C%BA%E5%99%A8%E8%A7%86%E8%A7%89/">机器视觉</a>
</div>
<div class="word_count">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="ri-quill-pen-line"></i>
<span class="post-meta-item-text"> 字数统计:</span>
<span class="post-count">1.1k</span>
</span>
</span>
<span class="post-time">
|
<span class="post-meta-item-icon">
<i class="ri-book-open-line"></i>
<span class="post-meta-item-text"> 阅读时长≈</span>
<span class="post-count">3 分钟</span>
</span>
</span>
</div>
</div>
<div class="tocbot"></div>
<div class="article-entry" itemprop="articleBody">
<blockquote>
<p>我终于回来啦,快一个月没有正式写博客了<br>最近忙着把老师交给我的项目完成,又从老师经费里白嫖了好多好玩的硬件,网课都没咋听,今天介绍完这个小点,马上就要准备看模电了<br>其实我做项目时完全从0开始,所接触的东西也是零零散散的,我想表达的东西用面向新手的方式写出来,之后开始介绍软硬件结合的东西。<br>也可以加我的交流群,所有资料我会在群里分享出来哦:977947271<br>2020/5/30:<br>近日每天都有十几个很明显的小号加群,而且有的大号进群竟然打广告和卖不良物品,经我和群友讨论后,加群需要1元钱,但是进群后我会将钱退还给大家,只是为了过滤一些不好的人。</p>
</blockquote>
<blockquote>
<p>环境:win10、py3.6、yolov3</p>
</blockquote>
<a id="more"></a>
<h2 id="1、准备工作"><a href="#1、准备工作" class="headerlink" title="1、准备工作"></a>1、准备工作</h2><p><strong>1、yolo3源代码:</strong><a href="https://github.com/qqwweee/keras-yolo3" target="_blank" rel="noopener">github_keras-yolo3</a></p>
<p><strong>2、权重文件:</strong>:<a href="https://pjreddie.com/media/files/yolov3.weights" target="_blank" rel="noopener">官网_yolov3_weights</a>(点击直接下载)或者 我的百度网盘文件 链接:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">https://pan.baidu.com/s/<span class="number">1</span>YD5dtSrEkcBO0PRHO7eLlw </span><br><span class="line">提取码:<span class="number">1</span>uub</span><br></pre></td></tr></table></figure>
<p>我也有自己训练的只识别 person 的权重文件,有需要的话可以评论邮箱地址<br>如果你是新手中的新手,可以先参考下我的这两篇文章:<br>1、<a href="https://blog.csdn.net/qq_45504119/article/details/105033492" target="_blank" rel="noopener">keras-yolov3目标检测详解——适合新手</a>(教你运行成功yolo)<br>2、<a href="https://blog.csdn.net/qq_45504119/article/details/105052478" target="_blank" rel="noopener">win10+yolov3+python训练自己的模型</a>(教你训练自己的模型去识别)</p>
<h2 id="2、添加yolo模型"><a href="#2、添加yolo模型" class="headerlink" title="2、添加yolo模型"></a>2、添加yolo模型</h2><p>先将 yolov3.weights 权重放在下载的yolo文件中</p>
<p><img src="https://img-blog.csdnimg.cn/20200504155521890.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>我这里用 pycharm 打开 yolo 源代码,<br>在命令行输入:<code>python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5</code></p>
<p><img src="https://img-blog.csdnimg.cn/20200504155725333.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>运行命令直到出现:<code>Saved Keras model to model_data/yolo.h5</code> </p>
<p><img src="https://img-blog.csdnimg.cn/20200504160013801.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>且 model_data 中多了个 yolo.h5 文件就代表准备工作完成了</p>
<p><img src="https://img-blog.csdnimg.cn/20200504160219163.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<h2 id="3、改代码并运行"><a href="#3、改代码并运行" class="headerlink" title="3、改代码并运行"></a>3、改代码并运行</h2><p>打开 yolo.py 大概在170多行的位置找到:<code>vid = cv2.VideoCapture(video_path)</code></p>
<p><img src="https://img-blog.csdnimg.cn/20200504160359383.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>将其改为:<code>vid = cv2.VideoCapture(0)</code></p>
<p>这里我们使用opencv库中的VideoCapture()函数创建摄像头对象,参数0是表示调用第一个摄像头,一般就是笔记本的内置摄像头。</p>
<p><img src="https://img-blog.csdnimg.cn/20200504160624971.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>然后打开 yolo_video.py 并运行<br>下面是我刚刚运行并演示出的效果,手机拿的有些近,所以没有识别出手机</p>
<p><img src="https://img-blog.csdnimg.cn/20200504161144308.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>不过细心的朋友看下代码就知道,其实这种方法实际上是读取摄像头某一帧的画面,对此画面进行图片式的识别。但是我们很多项目其实并不要求保存视频,或者处理的很流畅,我们需求就是单纯识别的话这种方法完全满足项目的需要了。<br>.</p>
<h2 id="4、用自己训练的模型来识别"><a href="#4、用自己训练的模型来识别" class="headerlink" title="4、用自己训练的模型来识别"></a>4、用自己训练的模型来识别</h2><p>上图有些瑕疵,只识别出了 person,但我拿开手机的话,我背后的很多物品,官方的权重都能识别,包括手机壳上的小狗。</p>
<p>但是很多情况下我们只想让他识别出一种或几种物品怎么办呢?</p>
<p>比如我之前训练出的只能识别出人的的权重,下面就介绍一下方法。</p>
<p>可以看我这篇文章:<a href="https://blog.csdn.net/qq_45504119/article/details/105052478" target="_blank" rel="noopener">win10+yolov3+python训练自己的模型——适合新手</a> 去自己训练出模型。</p>
<p>也可以直接用我训练的模型:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">链接:https://pan.baidu.com/s/<span class="number">1</span>NSR2XC-SmId9O1E0QvNGcg </span><br><span class="line">提取码:cs99</span><br><span class="line">>>>网盘下载的慢的话可以评论下邮箱,QQ传文件还是蛮快的<<<</span><br></pre></td></tr></table></figure>
<p>将我的模型下载好后放在 model_data 文件夹中,改名为:yolo.h5 </p>
<p><img src="https://img-blog.csdnimg.cn/20200504162339142.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>像上文一样运行 yolo_video.py 文件就可以了。</p>
<p><img src="https://img-blog.csdnimg.cn/20200504163355373.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>我也只是个学生,做项目的时候刚好看到 yolo 了,就玩了一阵子,这些只是很简单的东西,之后我会慢慢的把我做的比较深入的东西写出来(说实话…一般没人看),所以呢,今天2020/5/4,我准备创建一个开源项目的交流群。<br>我本身很菜,但是玩过一些开源的项目,本身电气专业,也喜欢自己用单片机做东西,现在自己发过论文、国际发明专利、国内发明专利。马上准备考研了,也希望能遇到一些大佬,给些指点,也可以大家一起讨论问题,解决问题。</p>
<p>群号:977947271<br><img src="https://img-blog.csdnimg.cn/20200504165237970.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1NTA0MTE5,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<!-- reward -->
</div>
<!-- copyright -->
<div class="declare">
<ul class="post-copyright">
<li>
<i class="ri-copyright-line"></i>
<strong>版权声明: </strong>
本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
</li>
</ul>
</div>
<footer class="article-footer">
<div class="share-btn">
<span class="share-sns share-outer">
<i class="ri-share-forward-line"></i>
分享
</span>
<div class="share-wrap">
<i class="arrow"></i>
<div class="share-icons">
<a class="weibo share-sns" href="javascript:;" data-type="weibo">
<i class="ri-weibo-fill"></i>
</a>
<a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
<i class="ri-wechat-fill"></i>
</a>
<a class="qq share-sns" href="javascript:;" data-type="qq">
<i class="ri-qq-fill"></i>
</a>
<a class="douban share-sns" href="javascript:;" data-type="douban">
<i class="ri-douban-line"></i>
</a>
<!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
<i class="icon icon-qzone"></i>
</a> -->
<a class="facebook share-sns" href="javascript:;" data-type="facebook">
<i class="ri-facebook-circle-fill"></i>
</a>
<a class="twitter share-sns" href="javascript:;" data-type="twitter">
<i class="ri-twitter-fill"></i>
</a>
<a class="google share-sns" href="javascript:;" data-type="google">
<i class="ri-google-fill"></i>
</a>
</div>
</div>
</div>
<div class="wx-share-modal">
<a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
<p>扫一扫,分享到微信</p>
<div class="wx-qrcode">
<img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://squansh.top/%E6%95%99%E5%A5%B3%E5%8F%8B%E5%AD%A6%E4%BC%9Apython+yolov3%E8%B0%83%E7%94%A8%E7%AC%94%E8%AE%B0%E6%9C%AC%E6%91%84%E5%83%8F%E5%A4%B4%E2%80%94%E2%80%94%E5%AE%9E%E6%97%B6%E8%BF%9B%E8%A1%8C%E8%AF%86%E5%88%AB.html" alt="微信分享二维码">
</div>
</div>
<div id="share-mask"></div>
<ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/python/" rel="tag">python</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%9C%BA%E5%99%A8%E8%A7%86%E8%A7%89/" rel="tag">机器视觉</a></li></ul>
</footer>
</div>
<nav class="article-nav">
<a href="/%E8%BF%90%E8%A1%8CSSD-TensorFlow%E6%8A%A5%E9%94%99%EF%BC%9Atensorflow.python.framework.errors_impl.NotFoundError%EF%BC%9A.html" class="article-nav-link">
<strong class="article-nav-caption">上一篇</strong>
<div class="article-nav-title">
运行SSD-TensorFlow报错:tensorflow.python.framework.errors_impl.NotFoundError:
</div>
</a>
<a href="/%E5%85%B3%E4%BA%8Eyolo%E9%85%8D%E5%90%88%E7%A1%AC%E4%BB%B6%E7%9A%84%E5%B0%8F%E7%BB%93%E2%80%94%E2%80%94%E4%B8%AA%E4%BA%BA%E7%AC%94%E8%AE%B0.html" class="article-nav-link">
<strong class="article-nav-caption">下一篇</strong>
<div class="article-nav-title">关于yolo配合硬件的小结——个人笔记</div>
</a>
</nav>
<!-- valine评论 -->
<div id="vcomments-box">
<div id="vcomments">
</div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/Valine.min.js'></script>
<script>
new Valine({
el: '#vcomments',
app_id: 'bMSQYcOX9RQgHRwGmc2xl2iY-9Nh9j0Va',
app_key: 'fhWrk4asGBlMT45CQdjPoEx4',
path: window.location.pathname,
notify: true,
verify: true,
avatar: 'monsterid',
placeholder: '给我的文章加点评论吧~',
recordIP: true
});
const infoEle = document.querySelector('#vcomments .info');
if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
infoEle.childNodes.forEach(function (item) {
item.parentNode.removeChild(item);
});
}
</script>
<style>
#vcomments-box {
padding: 5px 30px;
}
@media screen and (max-width: 800px) {
#vcomments-box {
padding: 5px 0px;
}
}
#vcomments-box #vcomments {
background-color: #fff;
}
.v .vlist .vcard .vh {
padding-right: 20px;
}
.v .vlist .vcard {
padding-left: 10px;
}
</style>
</article>
</section>
<footer class="footer">
<div class="outer">
<ul>
<li>
<span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span>
<script>
var now = new Date();
function createtime() {
var grt= new Date("06/01/2020 00:00:00");//在此处修改你的建站时间,格式:月/日/年 时:分:秒
now.setTime(now.getTime()+250);
days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
document.getElementById("timeDate").innerHTML = "本站已安全运行 "+dnum+" 天 ";
document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒";
}
setInterval("createtime()",250);
</script>
</li>
</ul>
<ul>
<li>
Copyrights ©
2020
<i class="ri-heart-fill heart_icon"></i> squansh
</li>
</ul>
<ul>
<li>
<span>
<span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></s>
<span class="division">|</span>
<span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
</li>
</ul>
<ul>
</ul>
<ul>
<li>
<!-- cnzz统计 -->
<script type="text/javascript" src="https://s4.cnzz.com/z_stat.php?id=1278953980&web_id=1278953980"></script>
</li>
</ul>
</div>
</footer>
<div class="float_btns">
<div class="totop" id="totop">
<i class="ri-arrow-up-line"></i>
</div>
<div class="todark" id="todark">
<i class="ri-moon-line"></i>
</div>
</div>
</main>
<aside class="sidebar on">
<button class="navbar-toggle"></button>
<nav class="navbar">
<div class="logo">
<a href="/"><img src="/images/photo_side.svg" alt="孙全胜의Space"></a>
</div>
<ul class="nav nav-main">
<li class="nav-item">
<a class="nav-item-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="/archives">Archives</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="/categories/">Categories</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="/tags">Tags</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="https://changyuqi.top/" target="_blank" rel="noopener">Sister</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="http://121.41.228.97/" target="_blank" rel="noopener">Bolo</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="https://quan_sheng_sun.gitee.io/resume" target="_blank" rel="noopener">Resume</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="https://jq.qq.com/?_wv=1027&k=KyptBBmy" target="_blank" rel="noopener">Qgroup</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="https://www.zhihu.com/people/jes331" target="_blank" rel="noopener">Zhi-h</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="https://weibo.com/5600672195" target="_blank" rel="noopener">Wei-b</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="https://blog.csdn.net/qq_45504119" target="_blank" rel="noopener">CSDN</a>
</li>
<li class="nav-item">
<a class="nav-item-link" href="mailto:[email protected]">E-mail</a>
</li>
</ul>
</nav>
<nav class="navbar navbar-bottom">
<ul class="nav">
<li class="nav-item">
<a class="nav-item-link nav-item-search" title="搜索">
<i class="ri-search-line"></i>
</a>
<a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
<i class="ri-rss-line"></i>
</a>
</li>
</ul>
</nav>
<div class="search-form-wrap">
<div class="local-search local-search-plugin">
<input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
<div id="local-search-result" class="local-search-result"></div>
</div>
</div>
<script type="text/javascript" src="//rf.revolvermaps.com/0/0/8.js?i=5uyif1eoo9j&m=0&c=ff0000&cr1=ffffff&f=arial&l=33&s=341&bv=85" async="async"></script>
</aside>
<!--浏览器搞笑标题-->
<script type="text/javascript" src="/js/FunnyTitle.js"></script>
<script>
if (window.matchMedia("(max-width: 768px)").matches) {
document.querySelector('.content').classList.remove('on');
document.querySelector('.sidebar').classList.remove('on');
}
</script>
<div id="mask"></div>
<!-- #reward -->
<div id="reward">
<span class="close"><i class="ri-close-line"></i></span>
<p class="reward-p"><i class="ri-cup-line"></i></p>
<div class="reward-box">
</div>
</div>
<script src="/js/jquery-2.0.3.min.js"></script>
<script src="/js/lazyload.min.js"></script>
<!-- Subtitle -->
<script>
try {
var typed = new Typed("#subtitle", {
strings: ['夜深了', '是否明天会悄然忘记', '夜却深了'],
startDelay: 0,
typeSpeed: 400,
loop: true,
backSpeed: 150,
showCursor: true
});
} catch (err) {
console.log(err)
}
</script>
<!-- Tocbot -->
<script src="/js/tocbot.min.js"></script>
<script>
tocbot.init({
tocSelector: '.tocbot',
contentSelector: '.article-entry',
headingSelector: 'h1, h2, h3, h4, h5, h6',
hasInnerContainers: true,
scrollSmooth: true,
scrollContainer: 'main',
positionFixedSelector: '.tocbot',
positionFixedClass: 'is-position-fixed',
fixedSidebarOffset: 'auto'
});
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/jquery.justifiedGallery.min.js"></script>
<script src="/dist/main.js"></script>
<!-- ImageViewer -->
<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
<!-- Background of PhotoSwipe.
It's a separate element as animating opacity is faster than rgba(). -->
<div class="pswp__bg"></div>
<!-- Slides wrapper with overflow:hidden. -->
<div class="pswp__scroll-wrap">
<!-- Container that holds slides.
PhotoSwipe keeps only 3 of them in the DOM to save memory.
Don't modify these 3 pswp__item elements, data is added later on. -->
<div class="pswp__container">
<div class="pswp__item"></div>
<div class="pswp__item"></div>
<div class="pswp__item"></div>
</div>
<!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
<div class="pswp__ui pswp__ui--hidden">
<div class="pswp__top-bar">
<!-- Controls are self-explanatory. Order can be changed. -->
<div class="pswp__counter"></div>
<button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
<button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>
<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
<!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
<!-- element will get class pswp__preloader--active when preloader is running -->
<div class="pswp__preloader">
<div class="pswp__preloader__icn">
<div class="pswp__preloader__cut">
<div class="pswp__preloader__donut"></div>
</div>
</div>
</div>
</div>
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
<div class="pswp__share-tooltip"></div>
</div>
<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
</button>
<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
</button>
<div class="pswp__caption">
<div class="pswp__caption__center"></div>
</div>
</div>
</div>
</div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/photoswipe-ui-default.min.js"></script>
<script>
function viewer_init() {
let pswpElement = document.querySelectorAll('.pswp')[0];
let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))
$imgArr.forEach(($em, i) => {
$em.onclick = () => {
// slider展开状态
// todo: 这样不好,后面改成状态
if (document.querySelector('.left-col.show')) return
let items = []
$imgArr.forEach(($em2, i2) => {
let img = $em2.getAttribute('data-idx', i2)
let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
let title = $em2.getAttribute('alt')
// 获得原图尺寸
const image = new Image()
image.src = src
items.push({
src: src,
w: image.width || $em2.width,
h: image.height || $em2.height,
title: title
})
})
var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
index: parseInt(i)
});
gallery.init()
}
})
}
viewer_init()
</script>
<!-- MathJax -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
var ayerConfig = {
mathjax: true
}
</script>
<!-- Katex -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"></script>
<!-- busuanzi -->
<script src="/js/busuanzi-2.3.pure.min.js"></script>
<!-- ClickLove -->
<script src="/js/clickLove.js"></script>
<!-- ClickBoom -->
<script src="/js/clickBoom.js"></script>
<!-- CodeCopy -->
<link rel="stylesheet" href="/css/clipboard.css">
<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
function wait(callback, seconds) {
var timelag = null;
timelag = window.setTimeout(callback, seconds);
}
!function (e, t, a) {
var initCopyCode = function(){
var copyHtml = '';
copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
copyHtml += '</button>';
$(".highlight .code pre").before(copyHtml);
$(".article pre code").before(copyHtml);
var clipboard = new ClipboardJS('.btn-copy', {
target: function(trigger) {
return trigger.nextElementSibling;
}
});
clipboard.on('success', function(e) {
let $btn = $(e.trigger);
$btn.addClass('copied');
let $icon = $($btn.find('i'));
$icon.removeClass('ri-file-copy-2-line');
$icon.addClass('ri-checkbox-circle-line');
let $span = $($btn.find('span'));
$span[0].innerText = 'COPIED';
wait(function () { // 等待两秒钟后恢复
$icon.removeClass('ri-checkbox-circle-line');
$icon.addClass('ri-file-copy-2-line');
$span[0].innerText = 'COPY';
}, 2000);
});
clipboard.on('error', function(e) {
e.clearSelection();
let $btn = $(e.trigger);
$btn.addClass('copy-failed');
let $icon = $($btn.find('i'));
$icon.removeClass('ri-file-copy-2-line');
$icon.addClass('ri-time-line');
let $span = $($btn.find('span'));
$span[0].innerText = 'COPY FAILED';
wait(function () { // 等待两秒钟后恢复
$icon.removeClass('ri-time-line');
$icon.addClass('ri-file-copy-2-line');
$span[0].innerText = 'COPY';
}, 2000);
});
}
initCopyCode();
}(window, document);
</script>
</div>
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"model":{"jsonPath":"/live2dw/assets/haruto.model.json"},"display":{"position":"right","width":260,"height":520},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>