spd-lib 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/t.py ADDED
@@ -0,0 +1,47 @@
1
+ import cv2
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+
5
+ # Load image and check it worked
6
+ img = cv2.imread('ooo.jpeg', cv2.IMREAD_GRAYSCALE)
7
+ if img is None:
8
+ raise FileNotFoundError("Image not found. Make sure 'your_image.jpg' is in the working directory.")
9
+
10
+ # Resize the image (downsample to 1/4 size)
11
+ small = cv2.resize(img, (img.shape[1] // 4, img.shape[0] // 4))
12
+
13
+ # Convert to binary (0 or 1) for exact pattern match
14
+ _, binary = cv2.threshold(small, 128, 1, cv2.THRESH_BINARY)
15
+
16
+ # Define mask
17
+ mask = np.array([
18
+ [1, 0, 1],
19
+ [0, 1, 0],
20
+ [0, 0, 0]
21
+ ])
22
+
23
+ # Prepare output image (same size as input)
24
+ highlighted = np.zeros_like(binary, dtype=np.uint8)
25
+
26
+ # Slide 3x3 window across binary image
27
+ for i in range(binary.shape[0] - 2):
28
+ for j in range(binary.shape[1] - 2):
29
+ window = binary[i:i+3, j:j+3]
30
+ if np.array_equal(window, mask):
31
+ highlighted[i+1, j+1] = 255 # Highlight center pixel
32
+
33
+ # Upscale result to original size for display
34
+ highlighted_large = cv2.resize(highlighted, (img.shape[1], img.shape[0]), interpolation=cv2.INTER_NEAREST)
35
+
36
+ # Display
37
+ plt.figure(figsize=(10,5))
38
+ plt.subplot(1,2,1)
39
+ plt.title("Original Grayscale")
40
+ plt.imshow(img, cmap='gray')
41
+ plt.axis('off')
42
+
43
+ plt.subplot(1,2,2)
44
+ plt.title("Exact Pattern Matches")
45
+ plt.imshow(highlighted_large, cmap='gray')
46
+ plt.axis('off')
47
+ plt.show()
package/test.js ADDED
@@ -0,0 +1,10 @@
1
+ const {SPD,SPD_LEG} = require('./src/index.js');
2
+ (async()=>{
3
+ const spd = new SPD()
4
+ await spd.setPassKey("hjon09*(NOINUIOSunons89h")
5
+ await spd.addData("call","fat")
6
+ const buffer= await spd.saveData("hjon09*(NOINUIOSunons89h")
7
+ const spd_ = await SPD.loadFromString(buffer,"hjon09*(NOINUIOSunons89h")
8
+ const d = await spd_.extractData()
9
+ console.log(d)
10
+ })()