2023年11月19日 星期日
CAPTCHA Demo
- 用 HTTP 讀取網頁並記錄此Session
- 以Beautiful Soup 解析HTML , 取出 CAPTCHA 所在的標籤, 另存圖片
- 對CAPTCHA圖片進行OCR , 解碼出文字
- 以HTTP Seesion 傳送解碼後的文字給Web Server

啓用WSGI Server + Flask 的版本
模仿瀏覽器的行為(使用session)
mimic the behavior of browser
session = requests.Session()
用sesson 送出 HTTP 請求(get/post) 會將session id 存在內部的cookie中。下次再發送session.post()或session.get() 會帶出相同的session-id . 否則會被認為這是不同的HTTP 請求。用這種方法才能將同一個請求,視為同一個對話(Session) 才能正確模仿瀏覽器的行為。2023年10月4日 星期三
Linux kernel : SPI device 兩種存取模式
Raw SPI Device Access
$ sudo modprobe spi_bcm2835
$ ls -l /dev/spidev*
crw-rw---- 1 root spi 153, 0 Nov 19 11:13 /dev/spidev0.0
crw-rw---- 1 root spi 153, 1 Nov 19 11:13 /dev/spidev0.1
Now everything is ready to access the SPI devices from a user-space application using the SPIDEV interface. There is abundant documentation in the Internet on how to use SPIDEV in application code.
Access SPI Flash as MTD
sudo modprobe mtd
sudo modprobe spi-nor
sudo insmod m25p80.ko
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00020000 "flash_uboot_env"
mtd1: 00a00000 00020000 "flash_linux_image"
mtd2: 005e0000 00020000 "flash_jffs2"
mtd3: 00100000 00010000 "spi_flash_part0"
mtd4: 00300000 00010000 "spi_flash_part1"
dev: size erasesize name
mtd0: 00020000 00020000 "flash_uboot_env"
mtd1: 00a00000 00020000 "flash_linux_image"
mtd2: 005e0000 00020000 "flash_jffs2"
mtd3: 00100000 00010000 "spi_flash_part0"
mtd4: 00300000 00010000 "spi_flash_part1"
2023年9月1日 星期五
2023年8月1日 星期二
LabelImg 的安裝與使用
LabelImg Tool: Annotations are saved as XML files in PASCAL VOC format, the format used by ImageNet. Besides, it also supports YOLO and CreateML formats.
下載 LabelImg ,
git clone https://github.com/HumanSignal/labelImg.git若沒有Python Qt, 則須安裝好QT5
pip install pyqt5_tools
接著再執行label Image 的工具
#For QT5 use this command,
pyrcc5 -o libs/resources.py resources.qrcpython labelImg.py
對某一個物件在所有圖片都標注完之後(記得存檔), 再回頭來標注另一個物件會比較快, 因為每框選一個物件,都要從下拉選擇選擇label 反而比較花時間!一個圖檔可能會有多個物件, 這些框選的資訊都記錄在對應的.txt 中。1.jpg -------> 1.txt2.jpg -------> 2.txt3.jpg -------> 3.txt .... ....
在yolo 模型, 其.txt 檔的內容, 每一列代表一個框框的資訊, 但以normalized的資訊來表示. 框框的物件座標資訊(x,y,w,h)都是相對於原始圖片的長宽,所以這些座標資訊都是介於0~1的數字class_id x y w hclass_id x y w h....#轉成0~1def convert(size, box): dw = 1./(size[0]) #圖片的寛 dh = 1./(size[1]) #圖片的高 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] x = x*dw w = w*dw y = y*dh h = h*dh return (x,y,w,h)
#yolo偵測到的物件其座標資訊須再乘回比例才可以得到原始圖片的座標資訊=========LabelImg 快速鍵,可以加快你標記的速度
Ctrl + u Load all of the images from a directory
從目錄加載所有圖像Ctrl + r Change the default annotation target dir
更改默認註釋目標目錄Ctrl + s Save 儲存 Ctrl + d Copy the current label and rect box
複製當前標籤和框Ctrl + Shift + d Delete the current image
刪除當前圖像Space Flag the current image as verified
將當前圖像標記為已驗證w Create a rect box
創建一個框d Next image 下一張圖片 a Previous image 上一張圖片 del Delete the selected rect box
刪除選中的矩形框Ctrl++ Zoom in 放大 Ctrl– Zoom out 縮小 ↑ → ↓ ← Keyboard arrows to move selected rect box "Flag the current image as verified" ,會出現綠色背景, 讓你可以快速事後檢查有沒有可能有遺漏的標記。若有綠色背景, 表示你已驗證過這張圖片已經檢查過了.
2023年7月31日 星期一
Raspberry 的預設帳號Pi 不存在了
基於安全性考量,Raspberry Pi 2022年開始的預載的OS image ,不再含有預設的pi 帳號了
在 SD 卡的boot 分割區 (SD 卡插在 Windows 上可以看到檔案系統), 建立一個名為userconf或userconf.txt的文件.
userconf.txt 的內容, 其中pi: <encrypted password>
此處以raspberry 作為密碼的編碼, 可以用其他Linux 機器產生 encrypted password
echo 'raspberry' | openssl passwd -6 -stdin
如此又可以回到帳號 pi 預設密碼為 raspberry 所習慣的環境了~
userconf.txt 的內容如下
訂閱:
文章
(
Atom
)






