tag:blogger.com,1999:blog-83479609849974953052024-03-19T13:01:50.688+08:00IT Lab艾鍗學院技術BlogCombining Education & FunROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.comBlogger369125tag:blogger.com,1999:blog-8347960984997495305.post-22063386937140804482024-02-19T15:42:00.001+08:002024-02-23T10:24:03.968+08:00計算題樣題-相關題型<p> </p><p></p><p class="MsoNormal"><span face="標楷體" style="color: #c00000; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">※僅先列出</span><span lang="EN-US" style="color: #c00000; font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;">”</span><span face="標楷體" style="color: #c00000; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">相關題型</span><span lang="EN-US" style="color: #c00000; font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;">”</span><span face="標楷體" style="color: #c00000; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">供參,為確知應試者邏輯</span><span lang="EN-US" style="color: #c00000; font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;">/</span><span face="標楷體" style="color: #c00000; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">運算能力,實際考題之數值將可能調整。</span><span lang="EN-US" style="color: #c00000; font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background: white; margin-bottom: 0cm; margin-left: 24.1pt; margin-right: 0cm; margin-top: 9.0pt; margin: 9pt 0cm 0cm 24.1pt; mso-list: l0 level1 lfo1; mso-pagination: widow-orphan; mso-para-margin-bottom: 0cm; mso-para-margin-left: 24.1pt; mso-para-margin-right: 0cm; mso-para-margin-top: .5gd; text-indent: -24.1pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">1.<span style="font: 7pt "Times New Roman";">
</span></span></span><!--[endif]--><u><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">下圖</span></u><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">為某班數學成績的次數分配折線圖,則下列敘述哪一個正確?</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
(A)<span style="mso-tab-count: 1;"> </span></span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">有人考</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">100</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">分</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><span style="mso-tab-count: 5;"> </span>(B)<span style="mso-tab-count: 1;"> </span></span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">恰有</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">12</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">人考</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">65</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">分</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
(C)<span style="mso-tab-count: 1;"> </span></span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">全班共有</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">46</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">人</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><span style="mso-tab-count: 5;"> </span>(D)<span style="mso-tab-count: 1;"> </span></span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">及格的人數剛好為全班人數</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
<span style="mso-no-proof: yes;"><!--[if gte vml 1]><v:shapetype id="_x0000_t75"
coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="圖片_x0020_5" o:spid="_x0000_i1030" type="#_x0000_t75"
style='width:197pt;height:92.5pt;visibility:visible;mso-wrap-style:square'
o:bordertopcolor="#fff200 pure" o:borderleftcolor="#fff200 pure"
o:borderbottomcolor="#fff200 pure" o:borderrightcolor="#fff200 pure">
<v:imagedata src="file:///C:/Users/ITTRAI~1/AppData/Local/Temp/msohtmlclip1/01/clip_image001.png"
o:title=""/>
<w:bordertop type="single" width="2"/>
<w:borderleft type="single" width="2"/>
<w:borderbottom type="single" width="2"/>
<w:borderright type="single" width="2"/>
</v:shape><![endif]--></span></span></p><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjQ47IyutMkPMx_WkyO8EXUzNq8VdLA9zIiqRW37TKLmI-CykWG5t90obzRX897ISQLFRYaiSMqdQZAqt-pzZFANRWt_V8SXaEB6bYaf8HynIu6cazX0u8tTKeWyPFEkJVAEaj2ZzqDFpYsXXDACjdkkQeA2xGCpH0pABzc1-Zw39vPNuPmbAlE8j00" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="195" data-original-width="412" height="151" src="https://blogger.googleusercontent.com/img/a/AVvXsEjQ47IyutMkPMx_WkyO8EXUzNq8VdLA9zIiqRW37TKLmI-CykWG5t90obzRX897ISQLFRYaiSMqdQZAqt-pzZFANRWt_V8SXaEB6bYaf8HynIu6cazX0u8tTKeWyPFEkJVAEaj2ZzqDFpYsXXDACjdkkQeA2xGCpH0pABzc1-Zw39vPNuPmbAlE8j00" width="320" /></a></div><br /><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><o:p></o:p></span><p></p>
<p class="MsoListParagraph" style="margin-bottom: 0cm; margin-left: 24.1pt; margin-right: 0cm; margin-top: 9.0pt; margin: 9pt 0cm 0cm 24.1pt; mso-list: l0 level1 lfo1; mso-para-margin-bottom: 0cm; mso-para-margin-left: 0gd; mso-para-margin-right: 0cm; mso-para-margin-top: .5gd; text-indent: -24.1pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">2.<span style="font: 7pt "Times New Roman";">
</span></span></span><!--[endif]--><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">某班男、女生共</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;">36</span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">人,調查他們喜歡的科目,如<u>下表</u>:</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體; mso-font-kerning: 0pt;"><br />
<span style="mso-no-proof: yes;"><!--[if gte vml 1]><v:shape id="圖片_x0020_8"
o:spid="_x0000_i1029" type="#_x0000_t75" style='width:240.5pt;height:91.5pt;
visibility:visible;mso-wrap-style:square' o:bordertopcolor="#fff200 pure"
o:borderleftcolor="#fff200 pure" o:borderbottomcolor="#fff200 pure"
o:borderrightcolor="#fff200 pure">
<v:imagedata src="file:///C:/Users/ITTRAI~1/AppData/Local/Temp/msohtmlclip1/01/clip_image003.png"
o:title=""/>
<w:bordertop type="single" width="2"/>
<w:borderleft type="single" width="2"/>
<w:borderbottom type="single" width="2"/>
<w:borderright type="single" width="2"/>
</v:shape><![endif]--></span></span></p><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhCsiFtKeAOHRnDHBQOPZORjLKdnPVf99GyLXgMB0D0uH8-UfD-NnbO1tfBJjrSgZOC3cFDuCYVzWE95zvxtjQLuTzVp6GZXnIGMPvm-gjxZadjBbpMyJqAfPpN3Lewh0NuGyimkXqB5nmArSaN1to2IysSRiYyiwP95GaRLi5zQlhlhV4x_sQCvnMW" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="193" data-original-width="503" height="123" src="https://blogger.googleusercontent.com/img/a/AVvXsEhCsiFtKeAOHRnDHBQOPZORjLKdnPVf99GyLXgMB0D0uH8-UfD-NnbO1tfBJjrSgZOC3cFDuCYVzWE95zvxtjQLuTzVp6GZXnIGMPvm-gjxZadjBbpMyJqAfPpN3Lewh0NuGyimkXqB5nmArSaN1to2IysSRiYyiwP95GaRLi5zQlhlhV4x_sQCvnMW" width="320" /></a></div><br /><br />
<span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-font-kerning: 0pt; mso-hansi-font-family: "Times New Roman";">下列敘述何者正確?</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體; mso-font-kerning: 0pt;"><br />
(A)<span style="mso-tab-count: 1;"> </span></span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-font-kerning: 0pt; mso-hansi-font-family: "Times New Roman";">全班喜歡數學的比例,和女生中喜歡數學的比例一樣多</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體; mso-font-kerning: 0pt;"><br />
(B)<span style="mso-tab-count: 1;"> </span></span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-font-kerning: 0pt; mso-hansi-font-family: "Times New Roman";">男生中喜歡數學的比例,比女生中喜歡數學的比例多</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體; mso-font-kerning: 0pt;"><br />
(C)<span style="mso-tab-count: 1;"> </span></span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-font-kerning: 0pt; mso-hansi-font-family: "Times New Roman";">男生中喜歡國文的比例,和女生中喜歡英文的比例一樣多</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體; mso-font-kerning: 0pt;"><br />
(D)<span style="mso-tab-count: 1;"> </span></span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-font-kerning: 0pt; mso-hansi-font-family: "Times New Roman";">男生中喜歡數學的比例,比女生中喜歡英文的比例多</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><o:p></o:p></span><p></p>
<p class="MsoNormal" style="background: white; margin-bottom: 0cm; margin-left: 24.1pt; margin-right: 0cm; margin-top: 9.0pt; margin: 9pt 0cm 0cm 24.1pt; mso-list: l0 level1 lfo1; mso-pagination: widow-orphan; mso-para-margin-bottom: 0cm; mso-para-margin-left: 24.1pt; mso-para-margin-right: 0cm; mso-para-margin-top: .5gd; text-indent: -24.1pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">3.<span style="font: 7pt "Times New Roman";">
</span></span></span><!--[endif]--><u><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">下圖</span></u><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">所示為某航空公司應徵人員身高的累積相對次數分配折線圖,若初選的條件為身高</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> 170</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">公分以上,則初選不合格的百分比應為多少?</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
(A) 45%<span style="mso-tab-count: 3;"> </span>(B) 50%<span style="mso-tab-count: 3;"> </span>(C) 65%<span style="mso-tab-count: 3;"> </span>(D) 70%<br />
<span style="mso-no-proof: yes;"><!--[if gte vml 1]><v:shape id="圖片_x0020_4"
o:spid="_x0000_i1028" type="#_x0000_t75" style='width:189.5pt;height:119.5pt;
visibility:visible;mso-wrap-style:square' o:bordertopcolor="#fff200 pure"
o:borderleftcolor="#fff200 pure" o:borderbottomcolor="#fff200 pure"
o:borderrightcolor="#fff200 pure">
<v:imagedata src="file:///C:/Users/ITTRAI~1/AppData/Local/Temp/msohtmlclip1/01/clip_image005.png"
o:title="" croptop="1342f"/>
<w:bordertop type="single" width="2"/>
<w:borderleft type="single" width="2"/>
<w:borderbottom type="single" width="2"/>
<w:borderright type="single" width="2"/>
</v:shape><![endif]--></span></span></p><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEi_j_2ehAt9fsytUbLV7wR-0UUwq5BNabdpYAE6SMv_HefYobpBzXgR1Ae0ahWO3UuL3NBeHRVPnuCeeEqlfB5m70Yv_cqrMsIurzcADcYHI5t9QcFwB07mbMzCk3BM1M5NEGPXvFtRo6YozxF7UR_sROt3lPPwcF1BpvG_3abBAJ70Q16uQ-O2WgPK" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="251" data-original-width="396" height="203" src="https://blogger.googleusercontent.com/img/a/AVvXsEi_j_2ehAt9fsytUbLV7wR-0UUwq5BNabdpYAE6SMv_HefYobpBzXgR1Ae0ahWO3UuL3NBeHRVPnuCeeEqlfB5m70Yv_cqrMsIurzcADcYHI5t9QcFwB07mbMzCk3BM1M5NEGPXvFtRo6YozxF7UR_sROt3lPPwcF1BpvG_3abBAJ70Q16uQ-O2WgPK" width="320" /></a></div><br /><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><o:p></o:p></span><p></p>
<p class="MsoNormal" style="background: white; margin-left: 24.1pt; mso-list: l0 level1 lfo1; mso-pagination: widow-orphan; text-indent: -24.1pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">4.<span style="font: 7pt "Times New Roman";">
</span></span></span><!--[endif]--><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">下表是某班</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">40</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">位學生第二次段考的數學成績,請問該班的平均分數應是多少?</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
(A) 65.25</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">分</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><span style="mso-tab-count: 3;"> </span>(B)
66.25</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">分</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><span style="mso-tab-count: 3;"> </span>(C)
67.25</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">分</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><span style="mso-tab-count: 1;"> </span><span style="mso-tab-count: 2;"> </span>(D) 68.25</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">分</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
<span style="mso-no-proof: yes;"><!--[if gte vml 1]><v:shape id="圖片_x0020_1"
o:spid="_x0000_i1027" type="#_x0000_t75" style='width:107pt;height:139.5pt;
visibility:visible;mso-wrap-style:square' o:bordertopcolor="#f2f2f2"
o:borderleftcolor="#f2f2f2" o:borderbottomcolor="#f2f2f2" o:borderrightcolor="#f2f2f2">
<v:imagedata src="file:///C:/Users/ITTRAI~1/AppData/Local/Temp/msohtmlclip1/01/clip_image007.png"
o:title="" cropright="3936f"/>
<w:bordertop type="single" width="2"/>
<w:borderleft type="single" width="2"/>
<w:borderbottom type="single" width="2"/>
<w:borderright type="single" width="2"/>
</v:shape><![endif]--></span></span></p><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgh8ab2XWsyt7gjCwFNn9qqhZfSzMgzXjrdU_ljCWJ5legdGr9UJefc6Cb585-VbkW5BqYCDHxmKycp5EUZG9CiXdK0O4d9lTHOz9AqqxRCwuBAhOXVo8gPxdniXhfUonwDFXtdwowr2LbL_zuGEquUCYkgqz7cnK01B3eKbneDtg7_3yBpAwbjsAB1" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="293" data-original-width="225" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEgh8ab2XWsyt7gjCwFNn9qqhZfSzMgzXjrdU_ljCWJ5legdGr9UJefc6Cb585-VbkW5BqYCDHxmKycp5EUZG9CiXdK0O4d9lTHOz9AqqxRCwuBAhOXVo8gPxdniXhfUonwDFXtdwowr2LbL_zuGEquUCYkgqz7cnK01B3eKbneDtg7_3yBpAwbjsAB1" width="184" /></a></div><br /><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><o:p></o:p></span><p></p>
<p class="MsoListParagraph" style="margin-bottom: 0cm; margin-left: 24.1pt; margin-right: 0cm; margin-top: 9.0pt; margin: 9pt 0cm 0cm 24.1pt; mso-list: l0 level1 lfo1; mso-para-margin-bottom: 0cm; mso-para-margin-left: 0gd; mso-para-margin-right: 0cm; mso-para-margin-top: .5gd; text-indent: -24.1pt;"><!--[if !supportLists]--><span lang="EN-US"><span style="font-family: Times New Roman, serif;">5.</span><span style="font: 7pt "Times New Roman";"> </span><span style="font-family: verdana;"><span style="font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-stretch: normal; font-style: normal; font-variant: normal; font-variation-settings: normal; font-weight: normal; line-height: normal;"> </span><span lang="EN-US">12÷2+6÷3×2</span></span></span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">的計算結果為?</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><br />
(A) 7<span style="mso-tab-count: 3;"> </span>(B) 10<span style="mso-tab-count: 3;"> </span>(C) 8<span style="mso-tab-count: 3;"> </span>(D) 16<o:p></o:p></span></p>
<p class="MsoNormal" style="background: white; margin-left: 24.1pt; margin-top: 9pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-pagination: widow-orphan; mso-para-margin-left: 24.1pt; mso-para-margin-top: .5gd; text-indent: -24.1pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">6.<span style="font: 7pt "Times New Roman";">
</span></span></span><!--[endif]--><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">已知有</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">5</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">個數由小到大排序為</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> a</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">、</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">b</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">、</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">c</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">、</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">d</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">、</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">e</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">,其平均數為</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> 321</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">,中位數為</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> 320</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">。</span><span style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> </span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">若</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">10a+35</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">、</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">10b+35</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">、</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">10c+35</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">、</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">10d+35</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">、</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">10e+35 </span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">的平均數為</span><span lang="EN-US" style="color: black; font-family: "Cambria Math",serif; mso-bidi-font-family: "Cambria Math"; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">𝑥</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">,中位數為</span><span lang="EN-US" style="color: black; font-family: "Cambria Math",serif; mso-bidi-font-family: "Cambria Math"; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">𝑦</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">,則</span><span lang="EN-US" style="color: black; font-family: "Cambria Math",serif; mso-bidi-font-family: "Cambria Math"; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">𝑥</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> </span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: "MS Gothic";">−</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> </span><span lang="EN-US" style="color: black; font-family: "Cambria Math",serif; mso-bidi-font-family: "Cambria Math"; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">𝑦</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> =<br />
(A) 10<span style="mso-tab-count: 3;"> </span>(B) 35<span style="mso-tab-count: 3;"> </span>(C) 321<span style="mso-tab-count: 3;"> </span>(D) 320</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="margin-bottom: 0cm; margin-left: 24.0pt; margin-right: 0cm; margin-top: 9.0pt; margin: 9pt 0cm 0cm 24pt; mso-list: l0 level1 lfo1; mso-para-margin-bottom: 0cm; mso-para-margin-left: 0gd; mso-para-margin-right: 0cm; mso-para-margin-top: .5gd; text-indent: -24pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">7.<span style="font: 7pt "Times New Roman";">
</span></span></span><!--[endif]--><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">中午</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;">12 </span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">點,<u>小明</u>到同一家餐廳外帶餐點,點了</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;">4</span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">份餐後,要結帳時,看到櫃台張貼:防疫期間,外帶優惠方式:每買</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;">5 </span><span face="標楷體" style="mso-ascii-font-family: "Times New Roman"; mso-hansi-font-family: "Times New Roman";">份餐,其中一個價格最便宜的餐可以免費,因此<u>小明</u>多買了一個香烤鯛魚飯,則<u>小明</u><b style="mso-bidi-font-weight: normal;">最多</b>只要再多付多少錢,就可以多買一個香烤鯛魚飯?</span><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><br />
(A) 40<span style="mso-tab-count: 3;"> </span>(B) 30<span style="mso-tab-count: 3;"> </span>(C) 20<span style="mso-tab-count: 3;"> </span>(D) 10<br /></span><span lang="EN-US" style="mso-no-proof: yes;"><br /></span></p><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhztidY9oATrAhtDKnhmC60l9m6BnNMBMkiZzDiIqPWHJJwnV_uJXKiwzc_TY7_zmgxgZWbyC0YVqSAnbTIP2BxE_4ihKxeccRzOJBByk9lCdKJzx19BF14WZ5Pq3IUHqX3SUpYw5ueGUr9k6KET0tsp981NXq11lHYEJ_I-b_4tj3dS-_DkNR-qi7H" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="252" data-original-width="528" height="153" src="https://blogger.googleusercontent.com/img/a/AVvXsEhztidY9oATrAhtDKnhmC60l9m6BnNMBMkiZzDiIqPWHJJwnV_uJXKiwzc_TY7_zmgxgZWbyC0YVqSAnbTIP2BxE_4ihKxeccRzOJBByk9lCdKJzx19BF14WZ5Pq3IUHqX3SUpYw5ueGUr9k6KET0tsp981NXq11lHYEJ_I-b_4tj3dS-_DkNR-qi7H" width="320" /></a></div><br /><!--[endif]--><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: 標楷體;"><o:p></o:p></span><p></p>
<p class="MsoNormal" style="background: white; margin-bottom: 0cm; margin-left: 24.0pt; margin-right: 0cm; margin-top: 9.0pt; margin: 9pt 0cm 0cm 24pt; mso-list: l0 level1 lfo1; mso-pagination: widow-orphan; mso-para-margin-bottom: 0cm; mso-para-margin-left: 24.0pt; mso-para-margin-right: 0cm; mso-para-margin-top: .5gd; text-indent: -24pt;"><!--[if !supportLists]--><span lang="EN-US" style="font-family: "Times New Roman",serif; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">8.<span style="font: 7pt "Times New Roman";">
</span></span></span><!--[endif]--><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">下圖為</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">2017</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">年九個國家,每百萬人器官捐贈率,則從下圖中,下列選項何者正確?</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"> <br />
(A) </span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">西班牙為</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">2017 </span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">年九個國家中,器官捐贈總人數最多的國家</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
(B) 2017</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">年九個國家中,台灣器官捐贈總人數多於中國器官捐贈總人數</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
(C) </span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">無法判斷葡萄牙和比利時兩國,捐贈器官總人數哪個國家多</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br />
(D) 2017</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">年九個國家中,香港器官捐贈總人數是第</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;">5</span><span face="標楷體" style="color: black; mso-ascii-font-family: "Times New Roman"; mso-bidi-font-family: "Times New Roman"; mso-color-alt: windowtext; mso-hansi-font-family: "Times New Roman";">多</span><span lang="EN-US" style="color: black; font-family: "Times New Roman",serif; mso-color-alt: windowtext; mso-fareast-font-family: 標楷體;"><br /><span style="mso-no-proof: yes;"><br /></span></span></p><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgGTfgJUW7KZJorGfniTFjt_Juyw-V10-gP0qLsZM-c1JUawq8TRRvrOjYJ6nHItEkRAk50zcqptZ2K9lJ_Ck_UDjFoS3g8o8IKBlIlk4eYZst0GZZO7zFBtrLdO-sYM-NWUNaqCQAoidKItRXEVMleyfW7Ohqta0i4aNe0gNdLLSjio7jtYj_Lq5KQ" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="261" data-original-width="443" height="189" src="https://blogger.googleusercontent.com/img/a/AVvXsEgGTfgJUW7KZJorGfniTFjt_Juyw-V10-gP0qLsZM-c1JUawq8TRRvrOjYJ6nHItEkRAk50zcqptZ2K9lJ_Ck_UDjFoS3g8o8IKBlIlk4eYZst0GZZO7zFBtrLdO-sYM-NWUNaqCQAoidKItRXEVMleyfW7Ohqta0i4aNe0gNdLLSjio7jtYj_Lq5KQ" width="320" /></a></div><div><br /></div>#其他補充<div><br /></div><div>[1] 何謂機器學習? <a href="https://blog.ittraining.com.tw/2022/03/blog-post.html">https://blog.ittraining.com.tw/2022/03/blog-post.html</a></div>艾鍗學院http://www.blogger.com/profile/05220192533988245041noreply@blogger.com1tag:blogger.com,1999:blog-8347960984997495305.post-69994208715644924432024-01-06T13:20:00.008+08:002024-02-07T19:32:11.621+08:003種不同的Bus bridge 連接HPS (ARM SoC)和 FPGA<p>FPGA Fabric 內部元件連接使用的是Avalon Bus, 而ARM SoC 內部使用 AXI Interface.</p><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;">Intel SoC FPGA 解決方案使用可以使用3種不同的bridge 連接HPS (ARM SoC)和 FPGA</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><ol style="text-align: left;"><li>HPS-to-FPGA Bridge : HPS ---> FPGA (for high perfromancee data transfer)</li><li>Lightweight HPS-to-FPGA Bridge: HPS ---> FPGA (for low perfromancee , fixed 32bit data width,tune for latency. suitable for control and status register access)</li><li>FPGA-to-HPS Bridge: FPGA---> HPS </li></ol></div></div><p></p><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqiOhnMDjPm10hR3EKibIxP3i5J0sKJDjxqWCGlSfLieO2AEX9ueO_6KxaaPWabJ3vIYbtc9ntzOF-nkcnNvN2F7_7pb89iIrfNwFEZjb82JvTTRs5WoaqWEgbVyn3u_T7tkYhsy1_KPGXCiGKptTxuER8wx-vizLdTJuZglJUUHmGgCZM3LvdeOtRJRo/s600/Interconnection-structure-between-FPGA-and-HPS.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="584" data-original-width="600" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqiOhnMDjPm10hR3EKibIxP3i5J0sKJDjxqWCGlSfLieO2AEX9ueO_6KxaaPWabJ3vIYbtc9ntzOF-nkcnNvN2F7_7pb89iIrfNwFEZjb82JvTTRs5WoaqWEgbVyn3u_T7tkYhsy1_KPGXCiGKptTxuER8wx-vizLdTJuZglJUUHmGgCZM3LvdeOtRJRo/s16000/Interconnection-structure-between-FPGA-and-HPS.jpg" /></a></div><br /><p></p><div>學習課程連結:</div><div><a href="https://www.ittraining.com.tw/ittraining/course/hardware/fpga">https://www.ittraining.com.tw/ittraining/course/hardware/fpga</a></div><div><a href="https://www.ittraining.com.tw/ittraining/course/hardware/soc-fpga">https://www.ittraining.com.tw/ittraining/course/hardware/soc-fpga</a></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-46866665411534919732023-11-21T09:59:00.005+08:002023-11-21T10:07:25.982+08:00使用OpenAI 的LLM<p><br /></p><p>OpenAI 目前提供的API 種類有這些: </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3OpPEfSvOmK_XNtZLV9TzqWbOj1nAMemcxtkexVcEtrYPo0bh6x65bLH-WFf5QBuvlLAUMyXsn6GAL4HwZpxIbFFNU4xfXybLq28UlsCNCVRPT-DIqMrg-HDOxL8jfvrkZ5LJ1Z6o2rrDl2VhDVxbjKfLP-SpC_n-3gv1rASdsW5dLhiAU7SDhq9j1Sc/s796/openAI_models.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="568" data-original-width="796" height="457" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3OpPEfSvOmK_XNtZLV9TzqWbOj1nAMemcxtkexVcEtrYPo0bh6x65bLH-WFf5QBuvlLAUMyXsn6GAL4HwZpxIbFFNU4xfXybLq28UlsCNCVRPT-DIqMrg-HDOxL8jfvrkZ5LJ1Z6o2rrDl2VhDVxbjKfLP-SpC_n-3gv1rASdsW5dLhiAU7SDhq9j1Sc/w640-h457/openAI_models.jpg" width="640" /></a></div><br /><p>但使用這些API ,要先在 OpenAI <a href="https://platform.openai.com/">https://platform.openai.com/</a> 註冊並取得API Key 才能呼叫。但取得API Key 是需要付費的。 使用 Free trial API Key 須付 5塊美金,此 Key 有效期為 3 個月。到期後,必須填寫信用卡資訊轉換成付費帳戶。</p><p>針對不同的AI模型, 如 聲音識別的 whisper-1, 文字生成影像 dall-e-2, 大型語言模型(LLM) gpt-3.5-turbo , 均有不同的使用資費。如下</p><p><br /></p><p></p><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitbnAe-mMMAsBrqoi3OTrYS0u41KC0FsXh3OAOVyswJ4aiFbPFxpYs2fnPdtaWTBMPqKtjE0W2bGn7_4eu-hNOk-5K8QXJFNV__V42RtmQpucCveJmxOWr61BYYnawHV7p8uxt7K2M0qW2Ii5ajj4id-idCgPdVDydGt5JudSQxlqQL2Ifi-7APyTIay8/s762/openAI.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="471" data-original-width="762" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitbnAe-mMMAsBrqoi3OTrYS0u41KC0FsXh3OAOVyswJ4aiFbPFxpYs2fnPdtaWTBMPqKtjE0W2bGn7_4eu-hNOk-5K8QXJFNV__V42RtmQpucCveJmxOWr61BYYnawHV7p8uxt7K2M0qW2Ii5ajj4id-idCgPdVDydGt5JudSQxlqQL2Ifi-7APyTIay8/s16000/openAI.jpg" /></a></div><br /><p><span face="Söhne, helvetica, sans-serif" style="color: #565869; font-size: 20px; font-weight: 700;">1. GET API Key</span></p><p> 1. <span face="Söhne, helvetica, sans-serif" style="color: #353740; font-size: 16px;">First, create an </span><a href="https://platform.openai.com/signup" style="box-sizing: border-box; color: #10a37f; cursor: pointer; font-family: Söhne, helvetica, sans-serif; font-size: 16px; text-decoration-line: none;">OpenAI account</a><span face="Söhne, helvetica, sans-serif" style="color: #353740; font-size: 16px;"> or </span><a href="https://platform.openai.com/login" style="box-sizing: border-box; color: #10a37f; cursor: pointer; font-family: Söhne, helvetica, sans-serif; font-size: 16px; text-decoration-line: none;">sign in</a><span face="Söhne, helvetica, sans-serif" style="color: #353740; font-size: 16px;">. Next, navigate to the </span><a href="https://platform.openai.com/account/api-keys" style="box-sizing: border-box; color: #10a37f; cursor: pointer; font-family: Söhne, helvetica, sans-serif; font-size: 16px; text-decoration-line: none;">API key page</a><span face="Söhne, helvetica, sans-serif" style="color: #353740; font-size: 16px;"> and "Create new secret key", optionally naming the key</span></p><p><span face="Söhne, helvetica, sans-serif" style="color: #565869; font-size: 20px; font-weight: 700;">2. Install the OpenAI Python library</span></p><p><span face="Söhne, helvetica, sans-serif" style="color: #353740;"> > pip install openai</span><span style="color: #eeeeee;"><span face="Söhne, helvetica, sans-serif"> </span><span face="Söhne, helvetica, sans-serif">langchain</span><span face="Söhne, helvetica, sans-serif"> </span></span></p><p><span style="color: #565869; font-size: 20px; font-weight: 700;">3. 程式測試</span></p><p><span face="Söhne, helvetica, sans-serif" style="color: #353740;"><br /></span></p><p><span face="Söhne, helvetica, sans-serif" style="color: #353740;"><br /></span></p><p><span face="Söhne, helvetica, sans-serif" style="color: #353740;"><br /></span></p><p><span face="Söhne, helvetica, sans-serif" style="color: #353740;"><br /></span></p>
<script src="https://gist.github.com/itrobotics/4839a002eb514285a82453aa1815de57.js"></script>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-60984158050014093542023-11-20T09:56:00.001+08:002023-11-20T09:57:28.744+08:00WSGI Server + Application Server(Flask)<p></p><div class="separator" style="clear: both; text-align: center;"><br /></div><br /> Flask 內部實現了精簡的 WSGI 接口, 不過這只適合在開發階段使用,因為效能不佳,所以進入到產品化階段,須使用性能高的WSGI 伺服器<p></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMEqF0fs-8lkFD4hpKgR2SVt3ZgyAnLLJ6SeJmFVr0uMaYjIR7KmN970Qh33kqJdPBZHo3iiAgk0KsNvIcH5RLZA7JWepCdGvfO-PPI2202HFaiVCvb1T60EzmkL78pFIDuqIc4yPcRZGzocCVZ52nK0pBwCBF2PYLsh8xaNQeMxeoCt_QyxbR4vgN6XQ/s905/wsgi.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="297" data-original-width="905" height="210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMEqF0fs-8lkFD4hpKgR2SVt3ZgyAnLLJ6SeJmFVr0uMaYjIR7KmN970Qh33kqJdPBZHo3iiAgk0KsNvIcH5RLZA7JWepCdGvfO-PPI2202HFaiVCvb1T60EzmkL78pFIDuqIc4yPcRZGzocCVZ52nK0pBwCBF2PYLsh8xaNQeMxeoCt_QyxbR4vgN6XQ/w640-h210/wsgi.png" width="640" /></a></div><p><br /></p><h2 style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 20px; font-weight: 500; line-height: 24px; margin: 0px;">WSGI Server + Application Server(Flask)</h2><p style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 12px 0px 0px; overflow-wrap: break-word; text-overflow: ellipsis;"># On Windows</p><p style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 12px 0px 0px; overflow-wrap: break-word; text-overflow: ellipsis;"><b> </b><span style="background-color: transparent;"> </span><span style="background-color: transparent;">原本python app.py 改成用waitress 啓動web 服務</span></p><p style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 12px 0px 0px; overflow-wrap: break-word; text-overflow: ellipsis;"> <b>pip install waitress</b></p><blockquote style="background-color: white; border-left: 2px solid var(--ds-border,#091e4224); box-sizing: border-box; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 12px 0px 0px; padding: 0px 0px 0px 16px;"><p style="margin: 0px; overflow-wrap: break-word; text-overflow: ellipsis;"><b>waitress-serve --host=0.0.0.0 --port=5000 app:app</b></p></blockquote><p><br /></p><p style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 12px 0px 0px; overflow-wrap: break-word; text-overflow: ellipsis;">#On Linux</p><p style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 12px 0px 0px; overflow-wrap: break-word; text-overflow: ellipsis;">可以用 gunicorn 作為WSGI Server</p><p style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 12px 0px 0px; overflow-wrap: break-word; text-overflow: ellipsis;">References:</p><p style="background-color: white; color: #172b4d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Droid Sans", "Helvetica Neue", sans-serif; font-size: 14px; margin: 12px 0px 0px; overflow-wrap: break-word; text-overflow: ellipsis;"><a class="atlaskit-smart-link" href="https://minglunwu.com/notes/2021/flask_plus_wsgi.html/" rel="noreferrer ugc nofollow" style="background-color: initial; text-decoration-line: none;" target="_blank"></a></p><div class="js-react-root" style="display: inline;"><a class="atlaskit-smart-link" href="https://minglunwu.com/notes/2021/flask_plus_wsgi.html/" rel="noreferrer ugc nofollow" style="text-decoration-line: none;" target="_blank"><span class="loader-wrapper"><span aria-expanded="false" aria-haspopup="true" data-testid="hover-card-trigger-wrapper"></span></span></a><a class="css-187a62q" data-testid="inline-card-resolved-view" href="https://minglunwu.com/notes/2021/flask_plus_wsgi.html/" role="button" style="-webkit-box-decoration-break: clone; border-radius: var(--ds-border-radius-100, 4px); border: 1px solid var(--ds-border, #DFE1E6); display: inline; line-height: 22px; padding: 2px 0px; text-decoration-line: none; transition: all 0.1s ease-in-out 0s; user-select: text;" tabindex="0"><span class="css-14tyax2" data-testid="inline-card-icon-and-title" style="-webkit-box-decoration-break: clone; padding: var(--ds-space-025, 2px) var(--ds-space-050, 4px); white-space-collapse: preserve; word-break: break-all;"><span class="css-1yitqmp" style="display: inline-block; margin-right: var(--ds-space-050, 4px); position: relative;"><span class="css-w2w4jx" style="display: inline-block; height: 0px; opacity: 0; width: 14px;"></span><img class="smart-link-icon css-fy7h5c" data-testid="inline-card-icon-and-title-image" src="https://minglunwu.com/img/favicon.ico" style="border-radius: 2px; border: 0px; cursor: pointer; height: 14px; left: 7px; margin-bottom: 0px; margin-right: var(--ds-space-050, 4px); max-width: 100%; position: absolute; top: 11px; transform: translate(-50%, -50%); user-select: none; vertical-align: middle; width: 14px;" /></span><span class="smart-link-title-wrapper css-0">Flask想上線? 你還需要一些酷東西</span></span></a></div><p></p>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-12280722903055977062023-11-19T22:40:00.004+08:002023-11-20T09:50:59.763+08:00OCR using Google vision APIOCR<div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWArntTLnrQupy6NDBmBs1rt1sYfG1Cro7dIGPxhd4scCUOPNc18lY_arJmDTvROyszH-Yc5V1vm3-FuWNd7m93hyphenhyphenpj0ZHF2Y0FFTJ5HY4kIfrIDi4V7_Bnz___9rUddqxg80hCqux2cwgU5D_PdaesYPX-chkchaCHcbArVU930aGaDUKtbIOXCM8Hds/s200/captcha.png" style="display: block; padding: 1em 0px; text-align: center;"></a><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWArntTLnrQupy6NDBmBs1rt1sYfG1Cro7dIGPxhd4scCUOPNc18lY_arJmDTvROyszH-Yc5V1vm3-FuWNd7m93hyphenhyphenpj0ZHF2Y0FFTJ5HY4kIfrIDi4V7_Bnz___9rUddqxg80hCqux2cwgU5D_PdaesYPX-chkchaCHcbArVU930aGaDUKtbIOXCM8Hds/s200/captcha.png" style="display: block; margin-left: auto; margin-right: auto; padding: 1em 0px; text-align: center;"></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaZWoCAhr6dEP_ouRqL-BGR8kfG-ycMxBAeih9SuOlAcqiVTuw_T76Q7bMZvR3VAEM9MWHqQ17i-MQ4KQd_yX5QKmHQrXq4kLT55fy7nQnCITM7hBPv7rh34X1hyHzqAb1pIfapTO3xHKxyKfwXAoNLG1-OIsqCLPxa8QT2oMp0hL2-aJBZqj8ODbdzdY/s417/ocr_google_vision.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="193" data-original-width="417" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaZWoCAhr6dEP_ouRqL-BGR8kfG-ycMxBAeih9SuOlAcqiVTuw_T76Q7bMZvR3VAEM9MWHqQ17i-MQ4KQd_yX5QKmHQrXq4kLT55fy7nQnCITM7hBPv7rh34X1hyHzqAb1pIfapTO3xHKxyKfwXAoNLG1-OIsqCLPxa8QT2oMp0hL2-aJBZqj8ODbdzdY/s16000/ocr_google_vision.png" /></a><div style="text-align: center;">OCR by google vision API </div></td></tr><tr><td class="tr-caption" style="text-align: center;"><br /></td></tr></tbody></table><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWArntTLnrQupy6NDBmBs1rt1sYfG1Cro7dIGPxhd4scCUOPNc18lY_arJmDTvROyszH-Yc5V1vm3-FuWNd7m93hyphenhyphenpj0ZHF2Y0FFTJ5HY4kIfrIDi4V7_Bnz___9rUddqxg80hCqux2cwgU5D_PdaesYPX-chkchaCHcbArVU930aGaDUKtbIOXCM8Hds/s200/captcha.png" style="display: block; padding: 1em 0px; text-align: center;"><br /></a><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWArntTLnrQupy6NDBmBs1rt1sYfG1Cro7dIGPxhd4scCUOPNc18lY_arJmDTvROyszH-Yc5V1vm3-FuWNd7m93hyphenhyphenpj0ZHF2Y0FFTJ5HY4kIfrIDi4V7_Bnz___9rUddqxg80hCqux2cwgU5D_PdaesYPX-chkchaCHcbArVU930aGaDUKtbIOXCM8Hds/s200/captcha.png" style="display: block; padding: 1em 0px; text-align: center;"><br /></a></div>
<script src="https://gist.github.com/itrobotics/571c86d03d8849bcf6076d958178057a.js?file=google_vision.py"></script>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-2573284444840923142023-11-19T19:33:00.009+08:002023-11-20T10:12:29.588+08:00CAPTCHA Demo<div class="separator" style="clear: both;"><br /></div><br /><ul style="text-align: left;"><li>用 HTTP 讀取網頁並記錄此Session</li><li>以Beautiful Soup 解析HTML , 取出 CAPTCHA 所在的標籤, 另存圖片</li><li>對CAPTCHA圖片進行<a href="http://blog.ittraining.com.tw/2023/11/google-vision-api-ocr.html">OCR</a> , 解碼出文字</li><li>以<a href="http://blog.ittraining.com.tw/2023/11/session.html">HTTP Seesion</a> 傳送解碼後的文字給Web Server </li></ul><p><br /></p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSfbzrB-_bSrcItOJv-bxHpmZS5Dlnq5EL0QSMxdsHuTvelolc0DaOEAQ2djiXLuRR5kK_K2U08gQEHUHLn_luTzkJ4LMnk9gMDC2zn0qqhmRac8E_W0kcwFSVAfqOLDOQoDCAYrKFpiOy7YDuyKbKKK5AzE1sRBn1gmDLgRJXiLW5_hXT3zlqZHWdSs/s1364/captcha_ocr_web.gif" style="display: block; padding: 1em 0px; text-align: center;"><img alt="" border="0" data-original-height="670" data-original-width="1364" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSfbzrB-_bSrcItOJv-bxHpmZS5Dlnq5EL0QSMxdsHuTvelolc0DaOEAQ2djiXLuRR5kK_K2U08gQEHUHLn_luTzkJ4LMnk9gMDC2zn0qqhmRac8E_W0kcwFSVAfqOLDOQoDCAYrKFpiOy7YDuyKbKKK5AzE1sRBn1gmDLgRJXiLW5_hXT3zlqZHWdSs/s400/captcha_ocr_web.gif" width="400" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSfbzrB-_bSrcItOJv-bxHpmZS5Dlnq5EL0QSMxdsHuTvelolc0DaOEAQ2djiXLuRR5kK_K2U08gQEHUHLn_luTzkJ4LMnk9gMDC2zn0qqhmRac8E_W0kcwFSVAfqOLDOQoDCAYrKFpiOy7YDuyKbKKK5AzE1sRBn1gmDLgRJXiLW5_hXT3zlqZHWdSs/s1364/captcha_ocr_web.gif" style="display: block; padding: 1em 0px; text-align: center;"><br /></a><div style="text-align: center;">啓用<a href="http://blog.ittraining.com.tw/2023/11/wsgi-server-application-serverflask.html">WSGI Server + Flask</a> 的版本</div><div style="text-align: center;"><br /></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibbAUb4XpoCPnrVIowVTYr6wOTIG8m-cnpZZd39sHrLXPuHm4gV017IF4YXN7m_yE9SGiwjiBdE-bJVOVSpw3t7-P89LGPWP5OP7kK2ENM3si191BsoE2PDBUm0UjMPW4uxwQUilyBT-2XPHq7yebd3Cj_z6K6yVf5v_eVcxEgZL6FUUTlrjJHowhd7r0/s1253/captcha_ocr_wsgi.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="696" data-original-width="1253" height="223" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibbAUb4XpoCPnrVIowVTYr6wOTIG8m-cnpZZd39sHrLXPuHm4gV017IF4YXN7m_yE9SGiwjiBdE-bJVOVSpw3t7-P89LGPWP5OP7kK2ENM3si191BsoE2PDBUm0UjMPW4uxwQUilyBT-2XPHq7yebd3Cj_z6K6yVf5v_eVcxEgZL6FUUTlrjJHowhd7r0/w400-h223/captcha_ocr_wsgi.gif" width="400" /></a></div><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSfbzrB-_bSrcItOJv-bxHpmZS5Dlnq5EL0QSMxdsHuTvelolc0DaOEAQ2djiXLuRR5kK_K2U08gQEHUHLn_luTzkJ4LMnk9gMDC2zn0qqhmRac8E_W0kcwFSVAfqOLDOQoDCAYrKFpiOy7YDuyKbKKK5AzE1sRBn1gmDLgRJXiLW5_hXT3zlqZHWdSs/s1364/captcha_ocr_web.gif" style="display: block; padding: 1em 0px; text-align: center;"><br /></a><br /><br /><p></p></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-64179393180017891832023-11-19T17:13:00.003+08:002023-11-19T22:40:57.792+08:00模仿瀏覽器的行為(使用session)<div class="separator" style="clear: both; text-align: center;"><br /></div><br /><p><br /></p><p>mimic the behavior of browser</p><p>session = requests.Session()</p>用sesson 送出 HTTP 請求(get/post) 會將session id 存在內部的cookie中。下次再發送session.post()或session.get() 會帶出相同的session-id . 否則會被認為這是不同的HTTP 請求。用這種方法才能將同一個請求,視為同一個對話(Session) 才能正確模仿瀏覽器的行為。<div><br /><div><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNKGXuUPD9riHmWpRGdpRZMbdp1iB0xMkP8k2ah3iylVtJIXCps6wLhQIZCk7xXqCUdPZnnxWP06SQ7DjOkl0iVuSguaIYkWqx-7Bh5g7VjGuSVOOmVQj4vlWWH9lAPE8om-5XgNV33ze-_KrHcgVEnJ43megkuU0RrpuwazAAnevmJeXtaqBmRl3LQ9g/s1345/captcha_web.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="670" data-original-width="1345" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNKGXuUPD9riHmWpRGdpRZMbdp1iB0xMkP8k2ah3iylVtJIXCps6wLhQIZCk7xXqCUdPZnnxWP06SQ7DjOkl0iVuSguaIYkWqx-7Bh5g7VjGuSVOOmVQj4vlWWH9lAPE8om-5XgNV33ze-_KrHcgVEnJ43megkuU0RrpuwazAAnevmJeXtaqBmRl3LQ9g/w400-h199/captcha_web.gif" width="400" /></a><br /><br /><br /><div><p>
<script src="https://gist.github.com/itrobotics/571c86d03d8849bcf6076d958178057a.js?file=session.get.py"></script>
</p></div></div></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-87589236308797176372023-10-04T11:15:00.001+08:002023-11-19T13:35:11.226+08:00Linux kernel : SPI device 兩種存取模式<p><br /></p><h2 style="text-align: left;"><strong style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><span style="font-size: large;">Raw SPI Device Access</span></strong></h2><p> $ sudo modprobe spi_bcm2835</p><div> $ ls -l /dev/spidev*</div><p>crw-rw---- 1 root spi 153, 0 Nov 19 11:13 <span style="color: red;">/dev/spidev0.0</span></p><p>crw-rw---- 1 root spi 153, 1 Nov 19 11:13 <span style="color: red;">/dev/spidev0.1</span></p><div><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;">Now everything is ready to access the SPI devices from a user-space application using the </span><span style="background-color: white; font-family: Courier; font-size: 12px;">SPIDEV</span><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"> interface. There is abundant documentation in the Internet on how to use </span><span style="background-color: white; font-family: Courier; font-size: 12px;">SPIDEV</span><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"> in application code. </span></div><div><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><br /></span></div><div><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><br /></span></div><div><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><br /></span></div><div><strong style="background-color: white; font-family: Arial, Helvetica, sans-serif;"><span style="font-size: large;">Access SPI Flash as MTD</span></strong></div><div><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><br /></span></div><div><span style="background-color: white; font-size: 12px;"><span style="font-family: Arial, Helvetica, sans-serif;"><div>sudo modprobe mtd</div><div>sudo modprobe spi-nor</div><div><div>sudo insmod m25p80.ko</div><div><br /></div></div></span></span></div><div><span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><br /></span></div><div><span style="background-color: #f3f5f7; font-family: Courier; font-size: 12px;">/ #</span><strong style="font-family: Courier; font-size: 12px;"> cat /proc/mtd</strong><br style="font-family: Courier; font-size: 12px;" /><span style="background-color: #f3f5f7; font-family: Courier; font-size: 12px;">dev: size erasesize name</span><br style="font-family: Courier; font-size: 12px;" /><span style="background-color: #f3f5f7; font-family: Courier; font-size: 12px;">mtd0: 00020000 00020000 "flash_uboot_env"</span><br style="font-family: Courier; font-size: 12px;" /><span style="background-color: #f3f5f7; font-family: Courier; font-size: 12px;">mtd1: 00a00000 00020000 "flash_linux_image"</span><br style="font-family: Courier; font-size: 12px;" /><span style="background-color: #f3f5f7; font-family: Courier; font-size: 12px;">mtd2: 005e0000 00020000 "flash_jffs2"</span><br style="font-family: Courier; font-size: 12px;" /><span style="background-color: #f3f5f7; font-family: Courier; font-size: 12px;">mtd3: 00100000 00010000 "spi_flash_part0"</span><br style="font-family: Courier; font-size: 12px;" /><span style="background-color: #f3f5f7; font-family: Courier; font-size: 12px;">mtd4: 00300000 00010000 "spi_flash_part1"</span></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-23832546935317859242023-09-01T17:11:00.003+08:002023-09-01T17:11:36.836+08:00 [Linux 系統程式設計] Pipe 與 fork<p><br /></p>(1) 先產生Pipe再做fork 和 fork 再產生Pipe 差別在哪?<div><br /></div><div><div>先產生Pipe 再Fork ==> parent/Child 可以交換資料</div><div>先 Fork 再產生pipe ==> parent/Child 各自應用, 而不是要交換資料 , pipe換成一般檔案也是相同的概念</div><div><br style="background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;" /></div><div><br /></div><div><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIC2FCfddBGEuOo2KPS-CQo3HgSVbzuZ2ubzMCcG9scq9r8pp3ow-Z6zTIug2F-6Wky5l9sCb6I7y0GItkaBAMXqGBdWvsAMkfGYi2B1PTkK58WDMgHubbdnW97O9avoY4OsO3i3wAUbbQBIQVCWBLe-g2Qn2_28ejVgQkz7U71nZMohlMVDM4EJtb8Zk/s796/pipe_before_fork.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="464" data-original-width="796" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIC2FCfddBGEuOo2KPS-CQo3HgSVbzuZ2ubzMCcG9scq9r8pp3ow-Z6zTIug2F-6Wky5l9sCb6I7y0GItkaBAMXqGBdWvsAMkfGYi2B1PTkK58WDMgHubbdnW97O9avoY4OsO3i3wAUbbQBIQVCWBLe-g2Qn2_28ejVgQkz7U71nZMohlMVDM4EJtb8Zk/s16000/pipe_before_fork.png" /></a><br /> <div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJTl73kEyEJPz1ueVPWKK68Kf3Bc76A0h7EB5zyvt5yNYKcSu6ZU7TYXBYxLmDYWWbPHEFdsCmJqkCshM79i3udH4o8za13g5137-0GQntCWKs-qQYp-JpFE6lJmtgZBg_5o9G8xgeA1Hs59TBJR6urAWDCIT5izlsXoNrJMWkNVduYqIo9bK0vAiu50Y/s822/message_queue.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="544" data-original-width="822" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJTl73kEyEJPz1ueVPWKK68Kf3Bc76A0h7EB5zyvt5yNYKcSu6ZU7TYXBYxLmDYWWbPHEFdsCmJqkCshM79i3udH4o8za13g5137-0GQntCWKs-qQYp-JpFE6lJmtgZBg_5o9G8xgeA1Hs59TBJR6urAWDCIT5izlsXoNrJMWkNVduYqIo9bK0vAiu50Y/s320/message_queue.png" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div><br /></div></div></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-67890956718905033152023-08-01T16:48:00.008+08:002023-11-15T11:31:39.248+08:00LabelImg 的安裝與使用<br />LabelImg Tool: <span face="-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"" style="background-color: white; color: #1f2328; font-size: 16px;">Annotations are saved as XML files in PASCAL VOC format, the format used by </span><a href="http://www.image-net.org/" rel="nofollow" style="background-color: white; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; text-decoration-line: none;">ImageNet</a><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"" style="background-color: white; color: #1f2328; font-size: 16px;">. Besides, it also supports YOLO and CreateML formats.</span><div><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #1f2328;"><br /></span></div><div><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #1f2328;"><br /></span>下載 LabelImg , <div><pre class="abk abl abm abn abo acg ach amn amo bf kv bq" style="background: rgb(242, 242, 242); border-radius: 0px; border: none; box-sizing: inherit; color: #242424; font-family: source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace; margin-bottom: 0px; margin-top: 56px; overflow-x: auto; padding: 20px;"><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" id="cd66" style="box-sizing: inherit; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="color: black; font-family: "Times New Roman"; font-size: medium; letter-spacing: normal; white-space-collapse: collapse;"><b>git clone https://github.com/HumanSignal/labelImg.git</b></span></span></pre></div><div><br /></div><div>若沒有Python Qt, 則須安裝好QT5 </div><div><b> </b></div><div><b>pip install pyqt5_tools</b></div><div><br /></div><div>接著再執行label Image 的工具</div><div><pre class="abk abl abm abn abo acg ach amn amo bf kv bq" style="background: rgb(242, 242, 242); border-radius: 0px; border: none; box-sizing: inherit; color: #242424; font-family: source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace; margin-bottom: 0px; margin-top: 56px; overflow-x: auto; padding: 20px;"><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" id="cd66" style="box-sizing: inherit; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;">#For QT5 use this command,<br style="box-sizing: inherit;" /><b>pyrcc5 -o libs/resources.py resources.qrc</b></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" id="e308" style="box-sizing: inherit; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><b>python labelImg.py</b></span><div><br /></div></pre></div><div><pre class="abk abl abm abn abo acg ach amn amo bf kv bq" style="background: rgb(242, 242, 242); border-radius: 0px; border: none; box-sizing: inherit; margin-bottom: 0px; margin-top: 56px; overflow-x: auto; padding: 20px;"><div class="separator" style="clear: both; color: #242424; font-family: source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyf2RrH9-L1uLO1qACB8CMymGEWVUgRqXwbZzyqfo0E-P-CQoiuLY4jhGM_wU-m9HS3PXAm_GWopavto3v9vSgjKd7MpuGoxtZkvsqVuTB81_--BxwzmnZko8RZgrFmSIDlJNb4ZDFEnFxfzPioW3tnA7sz9dvsrJ8iU1b45TwZPEagGEDmJDuy3tdq1M/s1011/yolo_labelimg.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="611" data-original-width="1011" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyf2RrH9-L1uLO1qACB8CMymGEWVUgRqXwbZzyqfo0E-P-CQoiuLY4jhGM_wU-m9HS3PXAm_GWopavto3v9vSgjKd7MpuGoxtZkvsqVuTB81_--BxwzmnZko8RZgrFmSIDlJNb4ZDFEnFxfzPioW3tnA7sz9dvsrJ8iU1b45TwZPEagGEDmJDuy3tdq1M/s16000/yolo_labelimg.png" /></a></div><span face="source-code-pro, Menlo, Monaco, Courier New, Courier, monospace" style="color: #242424;"><br /></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;">對某一個物件在<span style="letter-spacing: -0.022em;">所有圖片都標注完之後(記得存檔), 再回頭來標注另一個物件會比較快, 因為每框選一個物件,都要從下拉選擇選擇label 反而比較花時間!</span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;">一個圖檔可能會有多個物件, 這些框選的資訊都記錄在對應的.txt 中。</span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;">1.jpg -------> 1.txt</span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="letter-spacing: -0.352px;">2.jpg -------> 2.txt</span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="letter-spacing: -0.352px;">3.jpg -------> 3.txt</span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="letter-spacing: -0.352px;"> .... </span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="letter-spacing: -0.352px;"> .... </span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="letter-spacing: -0.022em;"><br /></span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="letter-spacing: -0.022em;">在yolo 模型, 其</span><span style="letter-spacing: -0.022em;">.txt 檔的內容, 每一列代表一個框框的資訊, 但以normalized的資訊來表示. </span>框框的物件座標資訊(x,y,w,h<span style="letter-spacing: -0.022em;">)都是相對於</span><span style="letter-spacing: -0.022em;">原始圖片的長宽,所以這些</span>座標資訊<span style="letter-spacing: -0.022em;">都是介於0~1的數字</span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="color: #242424;">class_id </span><span style="color: red;"> x y w h</span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="letter-spacing: -0.352px;"><span style="color: #242424;">class_id </span><span style="color: red;"> x y w h</span></span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><span style="letter-spacing: -0.352px;">....</span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;">#轉成0~1</span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" id="e308" style="box-sizing: inherit; display: block; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content;"><span face="source-code-pro, Menlo, Monaco, Courier New, Courier, monospace" style="color: #242424;"><span style="font-size: 16px; letter-spacing: -0.352px; text-wrap: wrap;">def convert(size, box):
dw = 1./(size[0]) #圖片的寛
dh = 1./(size[1]) </span></span><span face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" style="color: #242424; font-size: 16px; letter-spacing: -0.352px; text-wrap: wrap;">#圖片的高</span><span face="source-code-pro, Menlo, Monaco, Courier New, Courier, monospace"><span style="font-size: 16px; letter-spacing: -0.352px; text-wrap: wrap;"><span style="color: #242424;">
x = (box[0] + box[1])/2.0 - 1
y = (box[2] + box[3])/2.0 - 1
w = box[1] - box[0]
h = box[3] - box[2]
</span><span style="color: red;"> x = x*dw
w = w*dw
y = y*dh
h = h*dh</span><span style="color: #242424;">
return (x,y,w,h)</span></span></span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" id="e308" style="box-sizing: inherit; display: block; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content;"><span face="source-code-pro, Menlo, Monaco, Courier New, Courier, monospace"><span style="font-size: 16px; letter-spacing: -0.352px; text-wrap: wrap;"><span style="color: #242424;"><br /></span></span></span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" id="e308" style="box-sizing: inherit; display: block; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content;"><span face="source-code-pro, Menlo, Monaco, Courier New, Courier, monospace"><span style="font-size: 16px; letter-spacing: -0.352px; text-wrap: wrap;"><span style="color: #242424;"><span style="letter-spacing: -0.352px;">#yolo</span><span style="letter-spacing: -0.352px;">偵測到的</span><span style="letter-spacing: -0.352px;">物件其座標資訊須再乘回比例才可以得到</span><span style="letter-spacing: -0.352px;">原始圖片的</span><span style="letter-spacing: -0.352px;">座標資訊</span></span></span></span></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;">=========</span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;">LabelImg 快速鍵,可以加快你標記的速度<table class="alignleft" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: none; color: #656565; float: left; font-family: arial, "Microsoft JhengHei", 微軟正黑體, sans-serif; font-size: 16px; height: 200px; letter-spacing: normal; margin: 5px 20px 20px 0px; max-width: 100%; padding: 0px; table-layout: auto; text-align: center; width: 600px; word-break: break-all;"><tbody style="box-sizing: border-box; margin: 0px; padding: 0px;"><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border: 1px solid rgba(0, 0, 0, 0.08); box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">Ctrl + u</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 1px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Load all of the images from a directory<br style="box-sizing: border-box; margin: 0px; padding: 0px;" />從目錄加載所有圖像</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">Ctrl + r</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Change the default annotation target dir<br style="box-sizing: border-box; margin: 0px; padding: 0px;" />更改默認註釋目標目錄</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">Ctrl + s</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Save 儲存</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">Ctrl + d</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Copy the current label and rect box<br style="box-sizing: border-box; margin: 0px; padding: 0px;" />複製當前標籤和框</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">Ctrl + Shift + d</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Delete the current image<br style="box-sizing: border-box; margin: 0px; padding: 0px;" />刪除當前圖像</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">Space</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Flag the current image as verified<br style="box-sizing: border-box; margin: 0px; padding: 0px;" />將當前圖像標記為已驗證</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">w</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Create a rect box<br style="box-sizing: border-box; margin: 0px; padding: 0px;" />創建一個框</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">d</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Next image 下一張圖片</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">a</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Previous image 上一張圖片</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">del</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Delete the selected rect box<br style="box-sizing: border-box; margin: 0px; padding: 0px;" />刪除選中的矩形框</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">Ctrl++</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Zoom in 放大</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">Ctrl–</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Zoom out 縮小</td></tr><tr style="box-sizing: border-box; margin: 0px; padding: 0px;"><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 109px;"><span style="box-sizing: border-box; font-weight: 700; margin: 0px; padding: 0px;">↑ → ↓ ←</span></td><td style="border-color: rgba(0, 0, 0, 0.08); border-image: initial; border-style: solid; border-width: 0px 1px 1px 0px; box-sizing: border-box; margin: 0px; padding: 0.4em; width: 305px;">Keyboard arrows to move selected rect box</td></tr></tbody></table></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><br /></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><br /></span><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><br /></span><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">"Flag the current image as verified" ,會出現綠色背景, 讓你可以快速事後檢查有沒有可能有遺漏的標記。</div><div class="separator" style="clear: both; text-align: left;">若有綠色背景, 表示你已驗證過這張圖片已經檢查過了.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX33fs_IlE3PD93UOqOi6Tys-Q3ImrIlNDXfXFWjejqe8Q61ApB4VJafn0YA_bPNSwpakktWisxMz83I80p3W3haNwcYJPLiVdEYWkCfGpFAOObUZfarUWFZwO_fWXjV8Cfyu7SHJUQa1ty_1T7_D9KBI_RIRebtHC6haOSiWSn_4ZoaibdwlSTPwFou4/s1026/labelimg_verify.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="716" data-original-width="1026" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX33fs_IlE3PD93UOqOi6Tys-Q3ImrIlNDXfXFWjejqe8Q61ApB4VJafn0YA_bPNSwpakktWisxMz83I80p3W3haNwcYJPLiVdEYWkCfGpFAOObUZfarUWFZwO_fWXjV8Cfyu7SHJUQa1ty_1T7_D9KBI_RIRebtHC6haOSiWSn_4ZoaibdwlSTPwFou4/s16000/labelimg_verify.png" /></a></div><br /><span class="amp acl ur ach b fp ams amr s wm acp" data-selectable-paragraph="" face="source-code-pro, Menlo, Monaco, "Courier New", Courier, monospace" id="e308" style="box-sizing: inherit; color: #242424; display: block; font-size: 16px; letter-spacing: -0.022em; line-height: 1.18; margin-bottom: -0.09em; margin-top: 0.91em; min-width: fit-content; text-wrap: wrap;"><br /></span></pre></div></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-25407022675946866702023-07-31T16:48:00.010+08:002023-12-07T11:11:22.195+08:00Raspberry 的預設帳號Pi 不存在了<br /><br />基於安全性考量,Raspberry Pi 2022年開始的預載的OS image ,不再含有預設的pi 帳號了<br /><br />在 SD 卡的boot 分割區 (SD 卡插在 Windows 上可以看到檔案系統), 建立一個名為userconf或userconf.txt的文件. <br /><br />userconf.txt 的內容, 其中pi: <encrypted password><br /><br />此處以raspberry 作為密碼的編碼, 可以用其他Linux 機器產生 encrypted password<div><br /></div><div><b style="background-color: white; color: #222222; font-family: Roboto, sans-serif; font-size: 18px;">echo 'raspberry' | openssl passwd -6 -stdin</b><br />
</div><br />如此又可以回到帳號 pi 預設密碼為 raspberry 所習慣的環境了~<div><br /></div><div>userconf.txt 的內容如下<br /> <div><br /></div><div><br /></div><div><br /></div><div><br /></div>
<script src="https://gist.github.com/itrobotics/d5b3a5840600deb5e405f5b12a473700.js"></script></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-20520451933052982712023-01-14T12:49:00.009+08:002023-01-14T12:53:28.978+08:00[Python] 動態繪製不同尺寸的ASCII-table<p><br /></p><p>作業描述: 能動態繪製不同尺寸的ASCII-table</p><p style="text-align: left;">Task Decription:</p>1. Generate a random list of size 50.It contains random values from 1 to 50.<br />2. Dynamically draw a ASCII table according to the dimensions of table<div style="text-align: left;"><br /></div>The end result will look like below<div><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_TIGLHlXgFlngZ51nd7kvQ9Mmb3ek5rTyz6HwX4h-eQwMeZDF2pQCW0Vcss0NkB6kNR05CFfOHOBn04EgITxp7x5Pq7qTDOhkTfZgVMqtsRxebMtSMEw3kZMOGfQio-y_58lYtv6v0ZDZCuhWCXHtYEQnaRfGu9AdL1wfAbHvoXzH9r8zgXFvzrgm/s1330/hw1_create_table.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="652" data-original-width="1330" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_TIGLHlXgFlngZ51nd7kvQ9Mmb3ek5rTyz6HwX4h-eQwMeZDF2pQCW0Vcss0NkB6kNR05CFfOHOBn04EgITxp7x5Pq7qTDOhkTfZgVMqtsRxebMtSMEw3kZMOGfQio-y_58lYtv6v0ZDZCuhWCXHtYEQnaRfGu9AdL1wfAbHvoXzH9r8zgXFvzrgm/w640-h314/hw1_create_table.gif" width="640" /></a></div><br /><p></p></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-488222213192719692023-01-12T10:57:00.002+08:002023-01-12T11:03:44.663+08:00用Teachable Machine 建立模型<p> </p><h3 style="clear: both;">用Teachable Machine 建立模型</h3><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;">到Teachable Machine 網站 (<a href="https://teachablemachine.withgoogle.com" target="_blank">https://teachablemachine.withgoogle.com</a>/)</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">1. 建立類別名稱, 並上傳此類別的圖片</div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTSoayPzmqeEc1XmbnlXtTYF1HzBMFZqJszwKQFrfqaITNuXPcQvoDIfz38P6SRj6C03t581opBHxo7orB4DOeCAIThMOWkvTVS1n4l7KQaTrZB9iAVR0Oz8LPIHYRN_l5l5qb73UUCqUCnjJi-rwxpWrUIVuKdtN-FdgCfMqrYIuYuikfaeyEUT7b/s1359/20221231-215138-001.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="627" data-original-width="1359" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTSoayPzmqeEc1XmbnlXtTYF1HzBMFZqJszwKQFrfqaITNuXPcQvoDIfz38P6SRj6C03t581opBHxo7orB4DOeCAIThMOWkvTVS1n4l7KQaTrZB9iAVR0Oz8LPIHYRN_l5l5qb73UUCqUCnjJi-rwxpWrUIVuKdtN-FdgCfMqrYIuYuikfaeyEUT7b/w640-h296/20221231-215138-001.png" width="640" /></a></div><span><a name='more'></a></span><p><br /></p>2. 依序建立不同類別並上傳該類別的圖片. 這裡新增了 apple, banana, grape 共三個類別。接著按下中間的" Train Model " 就開始自動訓練模型了。不用寫任何程式碼,這就是No code 的AutoML概念。 <p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJYQGlxAQRp7qs7Q8TPRTumEUMeFpFTqLiLsPXtoGWm2NTTwbMvaaVmFnswRra-GUOF6D5ld3nfAebad2QV_wzKmhPcU9440t6tKHF_TWLA0NGa3wOre8IFDao2WruwHdOK7xg_NA8Cg-ZoftPHye65GAoh5lw0zhH9PM4bOa5YllXcWEXy_48N3Sn/s1355/20221231-215245-003.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="577" data-original-width="1355" height="272" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJYQGlxAQRp7qs7Q8TPRTumEUMeFpFTqLiLsPXtoGWm2NTTwbMvaaVmFnswRra-GUOF6D5ld3nfAebad2QV_wzKmhPcU9440t6tKHF_TWLA0NGa3wOre8IFDao2WruwHdOK7xg_NA8Cg-ZoftPHye65GAoh5lw0zhH9PM4bOa5YllXcWEXy_48N3Sn/w640-h272/20221231-215245-003.png" width="640" /></a></div><p>3. 最右側可以使用上傳讀片進行測試。同時也可以Export 此模型。</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjllgI1xyF6AR9Vdc_FrPLtydSlG-VHlMn3rct4Ye9y8uW-njWs0kWA32dPQi5cyS3PnERvniAGN1qoEUlO3qYwef6b3ifxalwCEJuCjODXIo3JdM0y1TGx1jFHy1R2NtG_y_Sd-VXZlN6XeU3jrRCOqcXw7Usfw9TIgNmUmA49y6cVDjQbdtymQ_Ps/s1355/20221231-215323-004.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="623" data-original-width="1355" height="294" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjllgI1xyF6AR9Vdc_FrPLtydSlG-VHlMn3rct4Ye9y8uW-njWs0kWA32dPQi5cyS3PnERvniAGN1qoEUlO3qYwef6b3ifxalwCEJuCjODXIo3JdM0y1TGx1jFHy1R2NtG_y_Sd-VXZlN6XeU3jrRCOqcXw7Usfw9TIgNmUmA49y6cVDjQbdtymQ_Ps/w640-h294/20221231-215323-004.png" width="640" /></a></div><p><br /></p><p><br /></p><p>4.Export 模型, 可以選擇不同的格式. 此例選擇Tensorflow 格式, 此用於PC端進行模型預測, 也就是本專案demo的模式。 Tensorflow 格式匯出會包含2個檔案, keras_model.h5 和 labels.txt 。模型預測的程式碼,在匯出按鋌的下方還提供程式碼可以真接copy拿來用,真的太貼心。</p><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi31OLywcG5wr48F_mdnwITlLFhZ22i1rWdMXedjOgM5uXafftwqDnEM4r7gaUEBwpgXXLQxpOU-mv0kaauirxhXIiL4-NEr1pew6ZNAjamtFajnxcJhV7Nb-8cBnbCg59AKQGMJufvtpKXzMKJTqimAV7hOd8KL7Nche5BheTLrsHrcSy8k8XXiaWF/s1358/20221231-215340-005.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="635" data-original-width="1358" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi31OLywcG5wr48F_mdnwITlLFhZ22i1rWdMXedjOgM5uXafftwqDnEM4r7gaUEBwpgXXLQxpOU-mv0kaauirxhXIiL4-NEr1pew6ZNAjamtFajnxcJhV7Nb-8cBnbCg59AKQGMJufvtpKXzMKJTqimAV7hOd8KL7Nche5BheTLrsHrcSy8k8XXiaWF/w640-h300/20221231-215340-005.png" width="640" /></a></div><br /><div class="separator" style="clear: both;"></div><div class="separator" style="clear: both;"><br /></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-35562942196655858842022-12-31T22:41:00.030+08:002023-07-12T16:11:56.907+08:00佈署AI模型於Web 上<p></p><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">目標: 用瀏覽器上傳圖案到Web後端進行預測, 並將模型預測結果回傳至瀏覽器。</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">#teachable machine #Flask #Keras </div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><pre class="a-b-r-La" style="background-color: white; font-family: "Courier New", Courier, monospace, arial, sans-serif; font-size: 14px; margin-bottom: 0px; margin-top: 0px; overflow-wrap: break-word; text-wrap: wrap; user-select: text;">#Install required packages
<span style="color: red;">pip install flask==2.1.1
pip install Pillow==9.1.0
pip install tensorflow==2.3.1
pip install keras==2.4.3</span></pre></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG0Ru55P4SaySB76lSZBFFxOQxs5u7FxTEnEc73eTIyFboH7iyZMjm93lIkL7dNYyAD0t5L2mEpfeKSmPBCoT6BRKYmyAn-rnrgUYY8louW5RCWaRehhp1w--lM9lGPucjEoU-TuW7ggTm4v_F630QhXOWKxQTI5CQ6ACZv3mXgx2Geud-ov64wRxk/s1020/flask_keras_classification.gif" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="635" data-original-width="1020" height="398" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG0Ru55P4SaySB76lSZBFFxOQxs5u7FxTEnEc73eTIyFboH7iyZMjm93lIkL7dNYyAD0t5L2mEpfeKSmPBCoT6BRKYmyAn-rnrgUYY8louW5RCWaRehhp1w--lM9lGPucjEoU-TuW7ggTm4v_F630QhXOWKxQTI5CQ6ACZv3mXgx2Geud-ov64wRxk/w640-h398/flask_keras_classification.gif" width="640" /></a></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">專案目錄結構如下, 其中model 資料匣 要放置AI 模型檔及Label 文字檔。凡應用是上傳圖片,由模型預測分類結果的, 都可以套用本專案程式架構。在不想改程式碼, 就直接模型檔名改成keras_model.h5 ,類別的文字檔改成 labels.txt。 </div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAH-ezLKcz6DkgVhDURm1v-egDU_FNKoyUQqxnGJ7s6VQLfpxuOQmfM4eMFn9xT3PcmQY4BQ6_sPu4by69T-IwA_gU0zQeWUKCmXeE8e8P5oBpwohU0Gc4MUqb6qkCtnIS3e1fJkWeHc9ibuoflaSW0YWjZm5QxXHiv59L54LMj8ONGzdX-KDRULXF/s716/20221231-215651-007.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="427" data-original-width="716" height="382" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAH-ezLKcz6DkgVhDURm1v-egDU_FNKoyUQqxnGJ7s6VQLfpxuOQmfM4eMFn9xT3PcmQY4BQ6_sPu4by69T-IwA_gU0zQeWUKCmXeE8e8P5oBpwohU0Gc4MUqb6qkCtnIS3e1fJkWeHc9ibuoflaSW0YWjZm5QxXHiv59L54LMj8ONGzdX-KDRULXF/w640-h382/20221231-215651-007.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p></p><div class="separator" style="clear: both; text-align: left;"> 執行主程式 main.py 後, 會載入模型同時啓動Web Server (Flask) </div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both;"><br /></div></div><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie9fZoJzN78xgZNxNBi2erO2uYRj3yK6ptAY1H3ipXYe8P8c9SdXieU6FwN8oswK0coA5uOp-0CwPde5MPI2fMrjzfOm2O2RXq1uYzAOBLdj5P3ptu97iCz67xQOpAKjK346lEPJwKpG497RCtVL6IDsXkRP0b8MnFjHfdnZcolzqVp9upI2Es5V_N/s1346/20221231-215707-008.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="714" data-original-width="1346" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie9fZoJzN78xgZNxNBi2erO2uYRj3yK6ptAY1H3ipXYe8P8c9SdXieU6FwN8oswK0coA5uOp-0CwPde5MPI2fMrjzfOm2O2RXq1uYzAOBLdj5P3ptu97iCz67xQOpAKjK346lEPJwKpG497RCtVL6IDsXkRP0b8MnFjHfdnZcolzqVp9upI2Es5V_N/w640-h340/20221231-215707-008.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div><br /></div>P.S. 此處 model 資料匣的所放的AI模型, 是直接使用 <a href="http://blog.ittraining.com.tw/2023/01/teachable-machine.html">Teachable Machine 來建立模型</a>。為了方便套用至其他的應用程式, 從teacbable machine 複製來的程式碼, 將其程式架構改寫為 Class 的方式,會比較好用。而且主程式會顯得很簡潔也會易於日後程式維護。aimodel.py 程式碼參考如下:<div><br /></div><div><br /></div><div><br /><div> </div><div><br /></div></div>
<script src="https://gist.github.com/itrobotics/5c8642aa492a4f17216aac1f4e2989f6.js"></script>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-53171227713998964602022-12-01T23:51:00.010+08:002022-12-02T00:32:14.163+08:00[Python] Python的變數僅僅只是一個tag<p> </p><p>在python 世界裡, 宣告的變數僅僅只是一個tag。而tag 可以到處貼, 所以當你問 tag 的資料型態時 , 那就是在問tag 當下所貼的位置的物件資料型態為何 ? </p><p>a=3 , 則 type(a)==> <b>int</b></p><p>b=3.14 , 則 type(b)==> <b>float</b></p><p>c="hello" , 則 type(c)==> <b>str</b></p><p>3, 3.14, "hello" 這都是物件, 佔有空間 ,而a, b, c 就是tag name, 只是一個名字用來存取物件而已。</p><p>python 的變數完全不同於C/C++ 變數的概念。C/C++ 變數是佔有空間的, 空間存放著資料, 而空間有多大就決定了資料的數值範圍。</p><p><b>int</b> a=64; (佔4個bytes)</p><p><b>char</b> ch='A'; (佔1個bytes)</p><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPsRBDnTQn7PxXjyC8Ga2NENVEDw6gsaj2mlid99k358mKjf2xClASP12EvGjRdsKs-V20J8dTu5f1w2iUG_vjWII5yjW61Kb-BtPguLzymz1Jw7RLvKIyMAVnk90U1Y7kg-JCn8dw2Q8bT3WKfsv5lNawW3tvN-wqrLHCcs31qyGavqVkjuPwOr-_/s753/python_lec_tag1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="497" data-original-width="753" height="422" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPsRBDnTQn7PxXjyC8Ga2NENVEDw6gsaj2mlid99k358mKjf2xClASP12EvGjRdsKs-V20J8dTu5f1w2iUG_vjWII5yjW61Kb-BtPguLzymz1Jw7RLvKIyMAVnk90U1Y7kg-JCn8dw2Q8bT3WKfsv5lNawW3tvN-wqrLHCcs31qyGavqVkjuPwOr-_/w640-h422/python_lec_tag1.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">Python 有Garbage collection 的機制, 故物件10沒有任何tag參考, Python 會自己回收。</div><div class="separator" style="clear: both; text-align: left;">Python 中的List , 它是一個container ,即它是具有一個空間。 如 a=[3,3,1] , a[0] 這個tag 指向物件3, a[1] 這個tag 也指向物件3, 而 a[2] 這個tag 指向物件1</div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeczgJetd3G-pJDD9xSnBiA1aUH23G8LQEp1GoEIX2CLeA-X60IHrRTi-pBnyD03PoWWDI4p7-QUJvBe03y_73KaitLMrBuFFSEyEA8EvohYcoR7J5-2do8t9foNCSV7RIjQeXfZpgR0wiTqUmcm-qRnB42Stwt57vzVg9K6hc7ydM62z4xC2-XKpo/s471/python_lec_list1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="471" data-original-width="426" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeczgJetd3G-pJDD9xSnBiA1aUH23G8LQEp1GoEIX2CLeA-X60IHrRTi-pBnyD03PoWWDI4p7-QUJvBe03y_73KaitLMrBuFFSEyEA8EvohYcoR7J5-2do8t9foNCSV7RIjQeXfZpgR0wiTqUmcm-qRnB42Stwt57vzVg9K6hc7ydM62z4xC2-XKpo/s16000/python_lec_list1.png" /></a></div><br /><p>你可能會問一個問題, Python 的變數用這樣搞有什麼好處?</p><p>用個例子說明好了, a=[1,2,3] </p><p>若要複製一份給c, 執行 c=a.copy() 就會將a的container 表格複製給c, 因為只是複製了container a 表格, 和資料物件多大沒有關係, 所以可以很快,也不用將相同的資料物件在記憶體中放兩份。若是C/C++ 則a, c 是各別的空間, 因此即使是相同的資料,在記憶體中也得各自存放一份,會比較佔空間,而且在複製資料時也得一個個byte 複製過去 ( memcpy),速度上也比較慢。</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibsdvgJSR-EhawG3CvW3OVwz_wNhZI2Ec0VCaswU9jRoxGFSG1mD8caaWqNrZDAYP_f4Nu1ZTgM-Rr4dHPnCc7_ttwv8T9XcrhEgoz1LiHHnkf6EmEKWvB4-n9hyDWoSgJ2oKH6A3ZssiIzZNTqEXBZdCy8vktFqxPR2jNYyhaVrjb8xeXsyIdZIUW/s491/python_lec_tag3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="306" data-original-width="491" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibsdvgJSR-EhawG3CvW3OVwz_wNhZI2Ec0VCaswU9jRoxGFSG1mD8caaWqNrZDAYP_f4Nu1ZTgM-Rr4dHPnCc7_ttwv8T9XcrhEgoz1LiHHnkf6EmEKWvB4-n9hyDWoSgJ2oKH6A3ZssiIzZNTqEXBZdCy8vktFqxPR2jNYyhaVrjb8xeXsyIdZIUW/s16000/python_lec_tag3.png" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2ATyiahfSYs5m5QvorEF0RpcXIE_SpwZynz89zH_vqIDnbU5YbXZerGiiYBNDp-lmb9kEN4j6AdllK90J5_XLxQpLUVKvqvCMer4Tmu1Z-vVLfhYKmK-c4aGbpBfAlUmpn7pSG_oXSwK17N5tJfNQ1Rx6USUZ9VCuaBjlg7RHhqhUWJfB2kPO-0sR/s661/python_lec2.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="496" data-original-width="661" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2ATyiahfSYs5m5QvorEF0RpcXIE_SpwZynz89zH_vqIDnbU5YbXZerGiiYBNDp-lmb9kEN4j6AdllK90J5_XLxQpLUVKvqvCMer4Tmu1Z-vVLfhYKmK-c4aGbpBfAlUmpn7pSG_oXSwK17N5tJfNQ1Rx6USUZ9VCuaBjlg7RHhqhUWJfB2kPO-0sR/s16000/python_lec2.jpg" /></a></div><br /><p></p>相關文章:<div><br /></div><div>[1] <a href="http://blog.ittraining.com.tw/2022/11/python.html">[Python] List is not what you think</a><br /><br /><br /><p><br /></p></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-11122132861389556992022-11-05T15:43:00.006+08:002022-11-06T09:46:38.396+08:00[Notepad ++]新增GNU ARM Assembly 語言格式<p> </p><h4 style="background-color: white; border: 0px; font-family: "Droid Sans", arial, sans-serif; font-size: 1.3em; font-stretch: normal; line-height: 1.4; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;">在Notepad ++編輯器新增GNU ARM Assembly 語言格式</h4><div><br /></div><div>1)下載 <a class="external text" href="http://notepad-plus.sourceforge.net/commun/userDefinedLang/userDefineLang_GNUARM_ASM.xml" rel="nofollow" style="color: #663366; font-family: sans-serif; font-size: 14px; line-height: 22.4px; padding-right: 13px; text-decoration-line: none;">ASM for ARM GNU</a>語言包 user defined languages</div><div><a href="http://docs.notepad-plus-plus.org/index.php/User_Defined_Language_Files">http://docs.notepad-plus-plus.org/index.php/User_Defined_Language_Files</a></div><div><br /></div><div><br /></div><div>2) 在[語言]->[定義程式語言] 然後, 匯入ASM for ARM GNU 語言包</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-HDRWLuvrBSA/V9tMjFQlZXI/AAAAAAAAE-w/VYSndMo1z9o5tQ-Iz_WkjTr4VPVX3s5CQCLcB/s1600/define_new_lang.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="522" src="https://2.bp.blogspot.com/-HDRWLuvrBSA/V9tMjFQlZXI/AAAAAAAAE-w/VYSndMo1z9o5tQ-Iz_WkjTr4VPVX3s5CQCLcB/s640/define_new_lang.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;">3) 匯入後可以再去修改, 例如, 原本ASM單行註解為只有 ; @ , 可再加入// (GNU GCC 是看得懂//為註解語法)</div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-dxf2QRXzH4w/V9tMjK_8kqI/AAAAAAAAE-0/jM2G_KMMEHQpVOvWE5YyAjodVZeBqNbFwCLcB/s1600/notepad%252B%252B.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://2.bp.blogspot.com/-dxf2QRXzH4w/V9tMjK_8kqI/AAAAAAAAE-0/jM2G_KMMEHQpVOvWE5YyAjodVZeBqNbFwCLcB/s640/notepad%252B%252B.png" width="600" /></a></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-26775669772071841862022-11-01T20:39:00.008+08:002022-12-01T23:55:15.489+08:00[Python] List is not what you think<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkB9dUoQpX9ywmK0ASkJ9WuYwHSGTEhgdU2Hp41tk4DSeQQFohZburllo_wpaFD-feqoI6kEQ0xBGwR5XHY6zPhEGldiG6KR64759qf2rGyTGGNeah2VF4SvnkJgnn8FNy72wsEBQTro58uQ7jL10i0HxnQ-lswalew0pMFJo1rXn1pAcC6fVctV14/s471/python_lec_list1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="471" data-original-width="426" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkB9dUoQpX9ywmK0ASkJ9WuYwHSGTEhgdU2Hp41tk4DSeQQFohZburllo_wpaFD-feqoI6kEQ0xBGwR5XHY6zPhEGldiG6KR64759qf2rGyTGGNeah2VF4SvnkJgnn8FNy72wsEBQTro58uQ7jL10i0HxnQ-lswalew0pMFJo1rXn1pAcC6fVctV14/s16000/python_lec_list1.png" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQuqcJAdZeWXA0Rm1S8Gqm8IYZmVVp5waRkvozXKt8hacnidMVM4ojtuWZc7bPo79FhWhDTP5BJ4v2aS_JL3geaBX2bhd9ev89s2dZQZE4b4lYyJlCNiiA33ogBmW3pamexHDT96enE_69s9J4KlGrHrpxI2DkrM5ve9EglQcliWOZmUHwEUpqntAh/s466/python_lec_list2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="453" data-original-width="466" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQuqcJAdZeWXA0Rm1S8Gqm8IYZmVVp5waRkvozXKt8hacnidMVM4ojtuWZc7bPo79FhWhDTP5BJ4v2aS_JL3geaBX2bhd9ev89s2dZQZE4b4lYyJlCNiiA33ogBmW3pamexHDT96enE_69s9J4KlGrHrpxI2DkrM5ve9EglQcliWOZmUHwEUpqntAh/s16000/python_lec_list2.png" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEsBLxUtHpx3xhnmiMKXOlTpZ3R6twD0eFFlkjt2vlB0EkOUMkob5Sw4fzYgsZlsS2mHzPk9el1Na5eE58FN8P1JOwLggEZQuBwcRJXgOa9-JgzH4h0LQXXyD_OdYJueFaVlxpRKIGIIs6XUev6GlgfdP3R8wuYmf71a5E5ss8zyE7BTLHyrqqWN9e/s653/python_lec_list3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="488" data-original-width="653" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEsBLxUtHpx3xhnmiMKXOlTpZ3R6twD0eFFlkjt2vlB0EkOUMkob5Sw4fzYgsZlsS2mHzPk9el1Na5eE58FN8P1JOwLggEZQuBwcRJXgOa9-JgzH4h0LQXXyD_OdYJueFaVlxpRKIGIIs6XUev6GlgfdP3R8wuYmf71a5E5ss8zyE7BTLHyrqqWN9e/s16000/python_lec_list3.png" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><p></p><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAR7HUajwA9vWVyZ8IkHu03oAc1TKzH7bbR_tr0UOfhswRRxuYeSRXDjgMlymJQg4Jmiktrewvlmgp6DLKCaJsZyazfx18dKf_5BXreYD7HKXj68CZKdMNsvJmNR-zpldyd71voJmfpKLyt-q3pBSUZkI6p-I36oKNGbQo-H-fdG0q7fxVEjRjzc1f/s662/python_lec1.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="495" data-original-width="662" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAR7HUajwA9vWVyZ8IkHu03oAc1TKzH7bbR_tr0UOfhswRRxuYeSRXDjgMlymJQg4Jmiktrewvlmgp6DLKCaJsZyazfx18dKf_5BXreYD7HKXj68CZKdMNsvJmNR-zpldyd71voJmfpKLyt-q3pBSUZkI6p-I36oKNGbQo-H-fdG0q7fxVEjRjzc1f/s16000/python_lec1.jpg" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><script src="https://gist.github.com/itrobotics/82241817696e72daeb3f8ed9030b99ab.js?file=python_list1.py"></script></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQis0b5wTCsqS41I0NxlkYsmYvJ57iZYWHYdsVgsUoIXQHVM0kE8GJxbr_MK4pfw-fHa15eB5pGv7cFRLotLy5DsSwg8MRu3rD7hF_XAJdvA1DSF_B2CEJ3BU_2266_qi9fsijhH3eaSXu2JjiAWWUZSYfjtXU_tVL_JfePLJeyFfBlW288ck8f1Nt/s490/python1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="248" data-original-width="490" height="162" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQis0b5wTCsqS41I0NxlkYsmYvJ57iZYWHYdsVgsUoIXQHVM0kE8GJxbr_MK4pfw-fHa15eB5pGv7cFRLotLy5DsSwg8MRu3rD7hF_XAJdvA1DSF_B2CEJ3BU_2266_qi9fsijhH3eaSXu2JjiAWWUZSYfjtXU_tVL_JfePLJeyFfBlW288ck8f1Nt/s320/python1.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><script src="https://gist.github.com/itrobotics/82241817696e72daeb3f8ed9030b99ab.js?file=python_list2.py"></script></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUEFWNMbzbhfqzEUVM168mGpJ_eOKOSKAIPBuEWJb-E_s0KIfQ3BicrSc91b7xcTOLnUfYmOPgExEZyy6Sfwx1fSHttqzxY-oNVMkThU4MRsFw0C_IjUeTV1NQ-WDTNAWl-3eWskzH1gNbIHRFQWr7dzljgAAyNg2RpV9c-n0ytqZsyMp3UxgRoysQ/s490/python2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="262" data-original-width="490" height="171" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUEFWNMbzbhfqzEUVM168mGpJ_eOKOSKAIPBuEWJb-E_s0KIfQ3BicrSc91b7xcTOLnUfYmOPgExEZyy6Sfwx1fSHttqzxY-oNVMkThU4MRsFw0C_IjUeTV1NQ-WDTNAWl-3eWskzH1gNbIHRFQWr7dzljgAAyNg2RpV9c-n0ytqZsyMp3UxgRoysQ/s320/python2.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><script src="https://gist.github.com/itrobotics/82241817696e72daeb3f8ed9030b99ab.js?file=python_list4.py"></script></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe2dSMDObO9oeHUfp5N1OifBi4RY-CBcIJ98JSdzWLPMpxWhf1Fsvk7Xe6eby-W6t8VyeqtyN8PMZ_PCWevZp7rzdSsNYAEy7U9yLlp6nXkpQNVfDUZ9zAL-sEKCTA7NuNpoqXf6soVRH23NXXImAD2q--EvJtbbiNrKMXk5SbmrZlG_0t7-bu3aLd/s570/python3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="356" data-original-width="570" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe2dSMDObO9oeHUfp5N1OifBi4RY-CBcIJ98JSdzWLPMpxWhf1Fsvk7Xe6eby-W6t8VyeqtyN8PMZ_PCWevZp7rzdSsNYAEy7U9yLlp6nXkpQNVfDUZ9zAL-sEKCTA7NuNpoqXf6soVRH23NXXImAD2q--EvJtbbiNrKMXk5SbmrZlG_0t7-bu3aLd/s320/python3.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><script src="https://gist.github.com/itrobotics/82241817696e72daeb3f8ed9030b99ab.js?file=python_list5.py"></script></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8x9mQ5h7P5OFQ6vZ1AXNGOyIZ7_68HhUC9j1U4tmQgGRuznBuofBrqf83QGI9POyH-V4GJq0bNI4z1NR71N-TzWz2ufjdUi5G1yK6C8IXXam5wC83acZ--myF-qBsoOVq1-9UjyMXZxMI9nAopBKNAnsPel0CtV6itSgMx_tvGGxPgFsT1x3LWb-I/s591/python4.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="385" data-original-width="591" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8x9mQ5h7P5OFQ6vZ1AXNGOyIZ7_68HhUC9j1U4tmQgGRuznBuofBrqf83QGI9POyH-V4GJq0bNI4z1NR71N-TzWz2ufjdUi5G1yK6C8IXXam5wC83acZ--myF-qBsoOVq1-9UjyMXZxMI9nAopBKNAnsPel0CtV6itSgMx_tvGGxPgFsT1x3LWb-I/s320/python4.png" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">相關文章: </div><div class="separator" style="clear: both; text-align: left;">[Python]<a href="http://blog.ittraining.com.tw/2022/12/python-pythontag.html"> Python的變數僅僅只是一個tag</a></div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="392" src="https://www.youtube.com/embed/RHvROP94qZ0" width="472" youtube-src-id="RHvROP94qZ0"></iframe></div><br /><div><br /></div><div><br /></div><div><br /></div><div><br /></div>References: <br /><br />[1]TensorFlow Lite for MCU <a href="https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbkJBMHlqb195MjRfRHRNYm5ENEx4dUhpRzRGQXxBQ3Jtc0tuOVBQcm4yVHgxX0QzbUhNRFdRd0szM1JKZzFtM0JmX1ZxcGs2WUJVZFYyRFFtWlJFY2UzTC1HdzlSOXpFLWNDZWZHcDN1VWRGWWZYR3U2NHdibWNzZGZWbDMwSWRERWx4MmxJODBWY2RkanRRUnVtRQ&q=https%3A%2F%2Fbit.ly%2F3j2fIIt&v=RHvROP94qZ0">https://bit.ly/3j2fIIt</a> <div>[2]AI機器學習&深度學習 <a href="https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbDI3Vkl1YjdUYXZzeXUydUFadlBGcEJaZEppZ3xBQ3Jtc0tuZkQ2RU9jWllGdXJTcEk1OUpnTzZ6ZjVYLS1YcHFITWczX2Q3bjdIZHdkTFB2S05MLTlDcjg3eldKajNHUEpFdFBhY3BVSHhITEV1anc1dXM0Znh3UjFuV1FIYW9kMjJYTjZicHZXRHVGdkItaDJWOA&q=http%3A%2F%2Fbit.ly%2F2KDZZz4&v=RHvROP94qZ0">http://bit.ly/2KDZZz4</a> </div><div>[3] AIoT智能聯網運算實戰(含OpenVINO) <a href="https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbFpGOW4zSVZIVEVPM0lwbUxfY2w3MVNXTjFwUXxBQ3Jtc0ttVmp4NF80b09xTjFwbVRETUdVcGdNWjhuczNhZkpWLXo1TXFpLWg4SjhSRm1SakZKM0Y0S0NWMldaZld2X1hvMEV1V2IzeHdBSEpiYlhYZFJuQjFvU1BpcHBZQUpRNlJpUWRubTVaanhRYzhPeVlsMA&q=http%3A%2F%2Fbit.ly%2F2IlIUK8&v=RHvROP94qZ0">http://bit.ly/2IlIUK8</a> </div><div>[4]AI自然語言與推薦系統應用 <a href="https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqblF0T0duSFRaUUJvT0x4elEzZ0x2RjdvWHlqQXxBQ3Jtc0ttTU5rNE5CRG1VeU04dGNfclBLd0ZOTXlUWGFWdE5ESkwwVVZfUnhOeFlaWXFYX25FRHY1dEpzd0R2NFQxUGZnZlpqbkJXSzRKMkhlUUpBZTJpTTVFRVM0VkRqaGpKdjVHNWRuSFNkRlFrcGJxZnFnYw&q=https%3A%2F%2Fbit.ly%2F3qnO2Tg&v=RHvROP94qZ0">https://bit.ly/3qnO2Tg</a> </div><div>[5]python程式設計 <a href="https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbml1U3F1Ri1vZEdpOUhrbFRyRGowREYycVZWd3xBQ3Jtc0tsaklKc0xXWTJUZmJ1Slg1NXMycHp2b0VGTXQ1NWxjejhoWTJuZjU3YTBIdGticEt1WncxTHl6Nk5mME5zb1NtYUJyNnRBSkdLNUhXb2JaT0R2MHMzSGtrQ21qWll0R2R3Snk3MWwtR2lRS2VmdWZjZw&q=https%3A%2F%2Fbit.ly%2F359cz4m&v=RHvROP94qZ0">https://bit.ly/359cz4m</a></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-87354419897652056032022-10-07T23:45:00.005+08:002022-10-08T14:33:37.289+08:00[Python] Why do we need frozenset ?<p>(1) <span style="color: red;">用frozenset 才可以用集合當作Key</span></p><p>Example:</p><p>itemsets=[{'B','C'},{'D'}] </p><p>count[{'B','C'}]+=1 # Error : "unhashable type: 'set'"</p><p>in this case, we can <span style="color: red;">use frozenset to make 'set' as a key</span></p><p>count[frozenset({'B','C'})]=1 <span style="color: red;"> </span></p><p><span style="color: red;"><span style="color: black;">(2) </span>用frozenset 才可以做集合包含集合</span></p><p> S=set()</p><p>e={'A','B','C'}</p><p>S.add (e) ==> 想要表示 S={{'A'},{'B'},{'C'}} --> TypeError: unhashable type: 'set' </p><p>S.add (frozenset(e)) -->OK S={frozenset({'A', 'B', 'C'})}</p><p><br /></p>
<script src="https://gist.github.com/itrobotics/39f352a3182eecbb022bebfa183c572a.js"></script>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-54009429754052748792022-08-29T11:59:00.005+08:002022-08-29T14:58:46.906+08:00[Raspberry Pi ] 查詢 Software and Hardware Version of a Raspberry Pi<p> </p>How to Check the Software and Hardware Version of a Raspberry Pi<div><br /></div><div> Type the following commands , you will get all information about Raspberry Pi<br /><ul style="text-align: left;"><li><span style="color: red;">cat /etc/os-release</span></li><li><span style="color: red;">uname -a</span></li><li><span style="color: red;">cat /proc/cpuinfo | grep Model</span></li></ul><p></p><p><span face="Google Sans, arial, sans-serif" style="color: #ea4335;"><br /></span><span face=""Google Sans", arial, sans-serif" style="background-color: white; color: #ea4335; font-size: 16px;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBKRuA_BK9V52sFRbKBhpxD5SOy4AwMcUmRMcDVnjqKOH-dxrLrm3mvbHhFb9wEYe2y2A0oXa-5rTIoKFZNQGuh1feADS0yveYvi9kh8WaCsNTcZDyc5IYu_f8jjOfVYpuxMvjKKCpRbNXvdNEe-8yrWyhywjyhgm6Ja47xntDeuhC3Qk6Tw28AHMz/s886/pi_version.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="352" data-original-width="886" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBKRuA_BK9V52sFRbKBhpxD5SOy4AwMcUmRMcDVnjqKOH-dxrLrm3mvbHhFb9wEYe2y2A0oXa-5rTIoKFZNQGuh1feADS0yveYvi9kh8WaCsNTcZDyc5IYu_f8jjOfVYpuxMvjKKCpRbNXvdNEe-8yrWyhywjyhgm6Ja47xntDeuhC3Qk6Tw28AHMz/s16000/pi_version.jpg" /></a></div></div><div><div><br /></div><div> 2019 年發布的Raspberry Pi 4 ,被發現有 USB-C 的充電問題,而小改款 v1.2 解決了此問題! </div></div><div><br /></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-50216320802846173972022-08-12T11:01:00.000+08:002022-08-12T11:01:01.309+08:00[Linux 程式設計] 關於GCC<p> </p><p><span style="color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;">1. 後面的-lxxxx 如果是linux他的位置在哪裡? </span></p><p><span style="background-color: #fcff01;"><span style="color: #2b00fe;">(base) ubuntu@ubuntu1804:/usr/lib$ <b>cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf</b></span></span></p><div style="-webkit-tap-highlight-color: transparent;"><br /></div><div style="-webkit-tap-highlight-color: transparent;"># Multiarch support</div><div style="-webkit-tap-highlight-color: transparent;">/usr/local/lib/x86_64-linux-gnu</div><div style="-webkit-tap-highlight-color: transparent;">/lib/x86_64-linux-gnu</div><div style="-webkit-tap-highlight-color: transparent;">/usr/lib/x86_64-linux-gnu</div><div style="-webkit-tap-highlight-color: transparent;">(base) ubuntu@ubuntu1804:/usr/lib$ pwd</div><div style="-webkit-tap-highlight-color: transparent;">/usr/lib</div><div><br /></div><div style="-webkit-tap-highlight-color: transparent; color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;">2. 標準函式庫為何不用帶-lxxx</div><div style="-webkit-tap-highlight-color: transparent; color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"><br /></div><div style="-webkit-tap-highlight-color: transparent; font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"><span style="color: #2b00fe;"> 因為gcc 預設會連結標準函式庫 libc.so.xx</span></div><div style="-webkit-tap-highlight-color: transparent; color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"><br /></div><div style="-webkit-tap-highlight-color: transparent; color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;">3. 如果使用opensource 專案時要使用 -lxxxx 這部分該怎使用如果他的lib名稱 不是lib<project></div><div style="-webkit-tap-highlight-color: transparent; color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"> </div><div style="-webkit-tap-highlight-color: transparent; font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"><span style="color: #2b00fe;"> 如果不是標準名稱就得用library全名. 主要還是要指定 -L<lib目錄> , 指名library的位置, 如果不是放在library 的搜尋路徑上的話</span></div><div style="-webkit-tap-highlight-color: transparent; color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"><br /></div><div style="-webkit-tap-highlight-color: transparent; color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"><br /></div><div style="-webkit-tap-highlight-color: transparent; color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"><br /></div><div style="-webkit-tap-highlight-color: transparent;"><div style="-webkit-tap-highlight-color: transparent;"><span style="color: #2b00fe; font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="background-color: #fcff01; font-size: 14px;">(base) ubuntu@ubuntu1804:~$ <b>gcc -v</b></span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="color: rgba(0, 0, 0, 0.870588235294118); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="background-color: #fcff01; font-size: 14px;"><br /></span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">Using built-in specs.</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">COLLECT_GCC=gcc</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">OFFLOAD_TARGET_NAMES=nvptx-none</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">OFFLOAD_TARGET_DEFAULT=1</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">Target: x86_64-linux-gnu</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">Thread model: posix</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><br /></span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><br /></span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">----------</span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">相關課程: </span></span></div><div style="-webkit-tap-highlight-color: transparent;"><span style="font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;">https://www.ittraining.com.tw/ittraining/it-elearning/el-linux-embedded/e-linuxsys#tab01</span></span></div><div style="color: rgba(0, 0, 0, 0.87); font-family: Roboto, RobotoDraft, Helvetica, Arial, sans-serif; font-size: 14px;"><br /></div></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-34610038372904312192022-08-01T13:06:00.010+08:002022-08-22T10:03:40.875+08:00Jupyter notebook 延伸工具<p> </p>超好用的2個Jupyter notebook 延伸工具<div><ul style="text-align: left;"><li>Table of content : 針對Markdown cell 提供目錄</li><li>autopep8: python代碼格式化工具</li></ul><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuLvVMeUuo3V_b6cvKTaSjKifV83XksOA5RuyKFEJ6JoVYaYTFFL2uLgJcPp1w2cX0Fx2kZ376pOCbaWMtz9Lef8lefxCy7pldm-_kTHa_IYbKvXpfc-JIoZ5c8Vubu65pMHdxq6VPMdBTXP-hUNPIoma1ZVmm-rhPshWJLcp5a8XP1Ym9VcuxuZdB/s1042/markdown.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="629" data-original-width="1042" height="386" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuLvVMeUuo3V_b6cvKTaSjKifV83XksOA5RuyKFEJ6JoVYaYTFFL2uLgJcPp1w2cX0Fx2kZ376pOCbaWMtz9Lef8lefxCy7pldm-_kTHa_IYbKvXpfc-JIoZ5c8Vubu65pMHdxq6VPMdBTXP-hUNPIoma1ZVmm-rhPshWJLcp5a8XP1Ym9VcuxuZdB/w640-h386/markdown.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div><br /></div><div><br /></div>(2) 安裝 Jupyter notebook extensions<div><br /></div><div>打開Anaconda Prompt , 執行</div><div><br /></div>pip install jupyter_contrib_nbextensions && jupyter contrib nbextension install</div><div><br /></div><div>(3) 重新開啓Jupyter Notebook, Enable "Table of content "</div><div><br /></div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgViQQOFgknDb69im7QyXMr0b14PlakmNCgNKJI7_bRa7FD74bJXGF_LnzXuVMeGc5xNSTD0qvMC4MBc0H6NmfIC0hUPf0WlmQISPrODO2M2B3TkoxEdhjrCnmrdDcMio1aKAp0uG8Ii_Fgx9vouknnNUu7GZdT2JYUPuVshe5RjbIDW2WdT5RE0O7z/s712/nbextension.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="324" data-original-width="712" height="293" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgViQQOFgknDb69im7QyXMr0b14PlakmNCgNKJI7_bRa7FD74bJXGF_LnzXuVMeGc5xNSTD0qvMC4MBc0H6NmfIC0hUPf0WlmQISPrODO2M2B3TkoxEdhjrCnmrdDcMio1aKAp0uG8Ii_Fgx9vouknnNUu7GZdT2JYUPuVshe5RjbIDW2WdT5RE0O7z/w640-h293/nbextension.png" width="640" /></a></div><div><br /></div><br /><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfPn4ElFYHzDMq-qD1zmDJ4oMFJkTEF7wABVvKTh_leyqOmJ3I8kxlYriQcAnXEZlTKakJaEFytE_wLLxkp2j7ZwuDu67wwBaDstH2ONiVTtRe2_xvpKZQ8mNOGUbLxVSTSWUpEyhM73BUdpS_LyGCrQcim_V_sBEmVMk7OnyqQ5wsUJMCCyaLOrmQ/s465/toc.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="364" data-original-width="465" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfPn4ElFYHzDMq-qD1zmDJ4oMFJkTEF7wABVvKTh_leyqOmJ3I8kxlYriQcAnXEZlTKakJaEFytE_wLLxkp2j7ZwuDu67wwBaDstH2ONiVTtRe2_xvpKZQ8mNOGUbLxVSTSWUpEyhM73BUdpS_LyGCrQcim_V_sBEmVMk7OnyqQ5wsUJMCCyaLOrmQ/s16000/toc.png" /></a></div><br />ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-15715776398223438862022-07-06T03:17:00.009+08:002022-07-10T10:32:19.712+08:00[Linux 系統程式設計] 關於sigaction 的 SA_RESTART flag<p> </p><p>Linux 系統程式設計</p><p><br /></p><pre style="color: #181818; font-family: monospace, courier; font-size: 16px; margin-left: 8px;"> <b style="color: #502000;">#include <signal.h></b>
<b style="color: #502000;">int sigaction(int </b><i style="color: #006000;">signum</i><b style="color: #502000;">, const struct sigaction *restrict </b><i style="color: #006000;">act</i><b style="color: #502000;">,</b>
<b style="color: #502000;">struct sigaction *restrict </b><i style="color: #006000;">oldact</i><b style="color: #502000;">);</b></pre><pre style="font-family: monospace, courier; font-size: 16px; margin-left: 8px;"><pre style="font-family: monospace, courier; margin-left: 8px;"><span style="color: #181818;"> The </span><i style="color: #006000;">sigaction</i><span style="color: #181818;"> structure is defined as something like:
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int </span><span style="color: red;">sa_flags</span><span style="color: #181818;">;
void (*sa_restorer)(void);
};</span></pre></pre><pre style="color: #181818; font-family: monospace, courier; font-size: 16px; margin-left: 8px;"><b style="color: #502000;"><br /></b></pre>在sigaction結構中, 有一個 sa_flags 欄位可以設定為 SA_RESTART , 這代表什麼意思呢? 原文如下<br /><pre style="color: #181818; font-family: monospace, courier; font-size: 16px; margin-left: 8px;"><b><span style="color: #2b00fe;">SA_RESTART </span></b>
<span> </span><span> </span>If a blocked call to one of the following interfaces is
interrupted by a signal handler, then the call is automatically
restarted after the signal handler returns if the <b style="color: #502000;">SA_RESTART </b>flag
was used; otherwise the call fails with the error <b style="color: #502000;">EINTR.</b></pre><br /><br />例如, Socket programming 的 accept() 就是一個blocked system call,當程序停留在這個系統呼叫時, 若收到signal 則會跳到對應的signal handler去執行, 那signal handler 執行完成後呢? <div><br /></div><div>其結果可以是繼續回到原呼叫 accept() 的狀態, 就好像沒有跳出去一樣, 或者讓 accept() 直接返回, 並且返回錯誤碼為 <b style="color: #502000; font-family: monospace, courier; font-size: 16px;">EINTR</b> . </div><div><br />OK, 那要繼續回到原呼叫 accept() 的狀態,,可以在<span style="color: #181818; font-family: monospace, courier; font-size: 16px;">sigaction結構的</span><span style="color: red;">sa_flags</span> 設定<b style="color: #181818; font-family: monospace, courier; font-size: 16px;"><span style="color: #2b00fe;">SA_RESTART </span></b>, 再呼叫sigaction() 中進行設定即可</div><div><br /></div><div><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #24292f;"><span style="font-size: 14px;"> </span></span><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; tab-size: 8;"></table><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #24292f;"><span style="font-size: 14px;"> struct sigaction sa;</span></span><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; tab-size: 8;"></table><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #24292f;"><span style="font-size: 14px;"> sa.sa_handler = &signal_handler;</span></span><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; tab-size: 8;"></table><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #2b00fe;"><span style="font-size: 14px;"> sa.sa_flags = SA_RESTART;</span></span><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; tab-size: 8;"></table><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #24292f;"><span style="font-size: 14px;"> sigfillset(&sa.sa_mask);</span></span><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; tab-size: 8;"></table><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #24292f;"><span style="font-size: 14px;"> if (sigaction(SIGUSR1, &sa, NULL) == -1) {</span></span><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; tab-size: 8;"></table><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #24292f;"><span style="font-size: 14px;"> fprintf(stderr,"error\n");</span></span><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; tab-size: 8;"></table><span face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji" style="color: #24292f;"><span style="font-size: 14px;"> }</span></span><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; tab-size: 8;"></table><table class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-paste-markdown-skip="" data-tab-size="8" data-tagsearch-lang="C" data-tagsearch-path="sigexp.c" style="background-color: white; border-collapse: collapse; border-spacing: 0px; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; tab-size: 8;"><tbody style="box-sizing: border-box;"></tbody></table></div><div><div><br /></div><div><br /><pre style="font-family: monospace, courier; font-size: 16px; margin-left: 8px;"><span style="color: #502000;"><b>More info: </b></span></pre><pre style="color: #181818; font-family: monospace, courier; font-size: 16px; margin-left: 8px;"><ul style="text-align: left;"><li><b style="color: #502000;"><a href="https://man7.org/linux/man-pages/man7/signal.7.html" style="font-family: "Times New Roman"; font-size: medium; font-weight: 400; white-space: normal;">https://man7.org/linux/man-pages/man7/signal.7.html</a></b></li><li><a href="https://www.ittraining.com.tw/ittraining/it-elearning/el-linux-embedded/e-linuxsys">Linux system programming </a></li></ul></pre><pre style="color: #181818; font-family: monospace, courier; font-size: 16px; margin-left: 8px;"><b style="color: #502000;"><br /></b></pre><pre style="color: #181818; font-family: monospace, courier; font-size: 16px; margin-left: 8px;"><b style="color: #502000;"><br /></b></pre><pre style="color: #181818; font-family: monospace, courier; font-size: 16px; margin-left: 8px;"><b style="color: #502000;"><br /></b></pre></div></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-263835881425594282022-06-25T11:55:00.016+08:002022-10-15T18:25:19.514+08:00UART over TTL/RS232 <p> </p>UART 是軟體層面的 serial 通訊協議(也可以借力 UART IC來完成)。定義baudrate, start bit, stop bit , data bit, parity check 等等, 但這些0和1都是只邏輯的0和1。而實際走的硬體訊號, 則要看使用的是TTL還是 RS232。TTL和 RS232 描述的是 Physical 電氣訊號。<div><div><div><br />TTL (transistor-transistor logic) 就是定義 0V 為 0,Vcc 為 1 , 一般 MCU、SoC 都會用的方式。 RS-232 定義 -3 to -25V 為 0, 而+3V~+25V為1。不過 RS232 是一個完善的標準通訊規範,所以尚包含硬體流量控制的機制及 Connector 的型式(如DB-9) 等內容。正常的PC 用的就是RS232 界面。不過若僅僅只是做基本的傳輸,不是拿來接數據機(Modem)這類的,其實也只是用了其中3條通訊線而已,TXD, RXD, GND。現在你懂了,為何 UART over TTL 只有3條訊號線的原因。</div><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoC0N9gq1Ovv4ncDEwkdLZumQM32JvCnbeGoUqgqwn85GTONr9cIZ9HhnCddqygv9AUVtBJNGzbpCDB0_dfBOikakQgx07_kxhqT4wDeCGEPRaLGqY35CiiRfv2_A5qsdMM6ondiQZbqqcbvlIcNSPf7TpYRTS92cRZwG4MLTbJi8cVVDjwSeBbd-b/s750/DB9-Pinout.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="500" data-original-width="750" height="426" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoC0N9gq1Ovv4ncDEwkdLZumQM32JvCnbeGoUqgqwn85GTONr9cIZ9HhnCddqygv9AUVtBJNGzbpCDB0_dfBOikakQgx07_kxhqT4wDeCGEPRaLGqY35CiiRfv2_A5qsdMM6ondiQZbqqcbvlIcNSPf7TpYRTS92cRZwG4MLTbJi8cVVDjwSeBbd-b/w640-h426/DB9-Pinout.jpg" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Source image: https://components101.com/<br /><br /></td></tr></tbody></table><div class="separator" style="clear: both; text-align: center;"><br /></div><div>PC(RS232)—----- UART ——MCU (5V), 因為電壓不同所以要做level shifter , 這可以使用MX232之類的IC來完成. UART over RS-232 (上) 及 UART over TTL (下) 傳送 01010101的電壓圖。總之,我送0/1, 你要解讀成0/1, 而不是解讀成1/0。</div><div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOlGBtIgqBBvO8HYo5Q1d8RlBFAJRyqSVB241bhvULvrAN-kEkQGaAz0z7nY7GniFnu0pjqlKOltvpC_a6GLaWSAz-jUBMhqzcT66d-0PR6vsjA1ur-vlEJFNwq7vjllF-TZuaudnt8gMWtotdJHksFGTEftHjYNajy-81olkhE4uv279eEmzJSQEv/s1216/ttl-timing.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="723" data-original-width="1216" height="381" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOlGBtIgqBBvO8HYo5Q1d8RlBFAJRyqSVB241bhvULvrAN-kEkQGaAz0z7nY7GniFnu0pjqlKOltvpC_a6GLaWSAz-jUBMhqzcT66d-0PR6vsjA1ur-vlEJFNwq7vjllF-TZuaudnt8gMWtotdJHksFGTEftHjYNajy-81olkhE4uv279eEmzJSQEv/w640-h381/ttl-timing.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Source Image: https://www.sparkfun.com/</td></tr></tbody></table><br /><p></p></div></div><div>相關文章: </div><div><br /></div><div>[1]<a href="http://blog.ittraining.com.tw/2020/07/xl430-w250-t-servo.html"> DYNAMIXEL Motor 控制使用TTL </a></div><div>[2] <a href="http://blog.ittraining.com.tw/2016/06/rs485-pin.html">嵌入式系統常用的通訊協定-RS485/Modbus</a></div></div><div><br /></div><div>相關課程: </div><div>[1] <a href="http://bit.ly/2IV0GnF">Linux 驅動程式設計</a> -實作LINUX UART/TTY Driver</div><div>[2] <a href="https://bit.ly/3CVNT19">ARM Boot loader 設計</a>-實作UART</div><div>[3] <a href="http://bit.ly/2IKemCB">MUC 韌體設計</a>-UART驅動</div><div><br /></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-5208280224055095102022-06-22T09:03:00.005+08:002022-09-09T11:14:13.397+08:00[C語言]字串處理函式:strspn, strpbrk<p></p><div><br /></div><div><br /></div><div>size_t <span style="color: #2b00fe;">strspn</span>(const char *str1, const char *str2) 傳回str1包含了str2 字串中的字元,共有有多少個。</div><div><div>char *<span style="color: #2b00fe;">strpbrk</span>(const char *str1, const char *str2) 傳回str1中出現str2字串中字元的位置。若沒有找到傳回NULL. </div></div><div><br /></div><div>char *d =strpbrk("my phone number is 23167736", "0123456789")</div><div>print("%c",d); ==> 卬出2</div><div><br /></div><div>========================</div><div><div class="separator" style="clear: both; text-align: center;"><br /></div></div><div> 以處理<a href="http://blog.ittraining.com.tw/2019/08/http-header-esp8266.html">HTTP header </a>的字串為例, 我們要逐行取出HTTP header的內容, 但要如何逐行進行呢? </div><div>以下是使用 strspn(), strpbrk() 函式來完成的</div><div> </div><div><br /></div><div><br /></div><div><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4hIOhh6RTwW2QCpMFMJ0iRBWaKbJxRIOh-17DDSBVV64lCZmzHLeS0ZEqJmSz2FgWscUxfvtEuo59XNNqm_xzDCW3GQIFv2k7-Uc3-ZDmDesvMge1IJzee4LyhuaexT6Ijs9hJQfehOmHbeD6xDjbHvEvANN-bXVVgAYxJHbinim3ASAaLmtS8IQC/s774/strpbrk.jpg" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="470" data-original-width="774" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4hIOhh6RTwW2QCpMFMJ0iRBWaKbJxRIOh-17DDSBVV64lCZmzHLeS0ZEqJmSz2FgWscUxfvtEuo59XNNqm_xzDCW3GQIFv2k7-Uc3-ZDmDesvMge1IJzee4LyhuaexT6Ijs9hJQfehOmHbeD6xDjbHvEvANN-bXVVgAYxJHbinim3ASAaLmtS8IQC/s16000/strpbrk.jpg" /></a></div><div><br /></div><div><div><br /></div><div>參考: </div><div>[1]程式參考
<script src="https://gist.github.com/itrobotics/61445305d19c50c2e77d7c9dc66dff7f.js"></script>
</div><div><br /></div><div><br /></div></div>[2] <a href="https://github.com/troglobit/merecat/blob/master/src/libhttpd.c">https://github.com/troglobit/merecat/blob/master/src/libhttpd.c</a><br /><div class="separator" style="clear: both;"><br /></div><p></p><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><p><br /></p>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0tag:blogger.com,1999:blog-8347960984997495305.post-61430177067620115252022-05-30T12:13:00.007+08:002022-05-30T12:14:34.892+08:00Disables dynamic cpufreq<p> </p><br /><br />Boot loader程式放入 Pi3中, 一開機剛開始跑的時候,LED 閃爍頻率都很正常 , 但大約經過約10秒左右 , 時間會變快 . 例如LED 0.5sec閃爍一次 , 經過10sec後變快小於0.5sec閃爍,是哪裡的設定需要再做調整修改 ?<div><br /></div><br /><br />#Disables<span style="color: red;"> dynamic cpufreq</span> driver<br /><br /> add this line "force_turbo=1" to config.txt . <div><br /></div><div>you can also google DVFS to get more information<br /> <br /><br /></div>ROBOThttp://www.blogger.com/profile/08617608118272116857noreply@blogger.com0