Skip to content

Commit c4a1f27

Browse files
committed
update
1 parent 4d1457e commit c4a1f27

23 files changed

Lines changed: 160 additions & 121 deletions

go.mod

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/richelieu-yang/chimera/v3
33
go 1.25.5
44

55
require (
6-
fyne.io/fyne/v2 v2.7.1
6+
fyne.io/fyne/v2 v2.7.2
77
github.com/alwindoss/morse v1.0.1
88
github.com/andybalholm/brotli v1.2.0
99
github.com/apache/pulsar-client-go v0.18.0
@@ -61,8 +61,8 @@ require (
6161
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
6262
github.com/klauspost/compress v1.18.2
6363
github.com/klauspost/cpuid/v2 v2.3.0
64-
github.com/linxGnu/grocksdb v1.10.3
65-
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20251231140407-f302c68012c5
64+
github.com/linxGnu/grocksdb v1.10.4
65+
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20260107080014-2cb7863112c8
6666
github.com/liuzl/gocc v0.0.0-20231231122217-0372e1059ca5
6767
github.com/magiconair/properties v1.8.10
6868
github.com/matoous/go-nanoid/v2 v2.1.0
@@ -120,7 +120,6 @@ require (
120120
go.opentelemetry.io/otel/trace v1.39.0
121121
go.uber.org/atomic v1.11.0
122122
go.uber.org/zap v1.27.1
123-
gocv.io/x/gocv v0.43.0
124123
golang.org/x/arch v0.23.0
125124
golang.org/x/crypto v0.46.0
126125
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93
@@ -157,7 +156,7 @@ require (
157156
cloud.google.com/go/iam v1.4.1 // indirect
158157
contrib.go.opencensus.io/exporter/ocagent v0.7.0 // indirect
159158
filippo.io/edwards25519 v1.1.0 // indirect
160-
fyne.io/systray v1.11.1-0.20250603113521-ca66a66d8b58 // indirect
159+
fyne.io/systray v1.12.0 // indirect
161160
github.com/AthenZ/athenz v1.12.13 // indirect
162161
github.com/BurntSushi/toml v1.6.0 // indirect
163162
github.com/ClickHouse/ch-go v0.61.5 // indirect

go.sum

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
197197
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
198198
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
199199
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
200-
fyne.io/fyne/v2 v2.7.1 h1:ja7rNHWWEooha4XBIZNnPP8tVFwmTfwMJdpZmLxm2Zc=
201-
fyne.io/fyne/v2 v2.7.1/go.mod h1:xClVlrhxl7D+LT+BWYmcrW4Nf+dJTvkhnPgji7spAwE=
202-
fyne.io/systray v1.11.1-0.20250603113521-ca66a66d8b58 h1:eA5/u2XRd8OUkoMqEv3IBlFYSruNlXD8bRHDiqm0VNI=
203-
fyne.io/systray v1.11.1-0.20250603113521-ca66a66d8b58/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
200+
fyne.io/fyne/v2 v2.7.2 h1:XiNpWkn0PzX43ZCjbb0QYGg1RCxVbugwfVgikWZBCMw=
201+
fyne.io/fyne/v2 v2.7.2/go.mod h1:PXbqY3mQmJV3J1NRUR2VbVgUUx3vgvhuFJxyjRK/4Ug=
202+
fyne.io/systray v1.12.0 h1:CA1Kk0e2zwFlxtc02L3QFSiIbxJ/P0n582YrZHT7aTM=
203+
fyne.io/systray v1.12.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
204204
github.com/AthenZ/athenz v1.12.13 h1:OhZNqZsoBXNrKBJobeUUEirPDnwt0HRo4kQMIO1UwwQ=
205205
github.com/AthenZ/athenz v1.12.13/go.mod h1:XXDXXgaQzXaBXnJX6x/bH4yF6eon2lkyzQZ0z/dxprE=
206206
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
@@ -946,10 +946,10 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx
946946
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
947947
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
948948
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
949-
github.com/linxGnu/grocksdb v1.10.3 h1:0laII9AQ6kFxo5SjhdTfSh9EgF20piD6TMHK6YuDm+4=
950-
github.com/linxGnu/grocksdb v1.10.3/go.mod h1:OLQKZwiKwaJiAVCsOzWKvwiLwfZ5Vz8Md5TYR7t7pM8=
951-
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20251231140407-f302c68012c5 h1:asQhXI6Tn9ncbSMGEwYxOfRZCkg+cBhgkSOXtTThS4M=
952-
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20251231140407-f302c68012c5/go.mod h1:+mNMTBuDMdEGhWzoQgc6kBdqeaQpWh5ba8zqmp2MxCU=
949+
github.com/linxGnu/grocksdb v1.10.4 h1:C9WZslnCjXxx+BL/fXCIe1pLhEri3V9vLQcBZOHadnU=
950+
github.com/linxGnu/grocksdb v1.10.4/go.mod h1:OLQKZwiKwaJiAVCsOzWKvwiLwfZ5Vz8Md5TYR7t7pM8=
951+
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20260107080014-2cb7863112c8 h1:fq+Im5OGRqpDtgZ5eCFXz0Rv6rzZKLY6zt1gi078RW4=
952+
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20260107080014-2cb7863112c8/go.mod h1:+mNMTBuDMdEGhWzoQgc6kBdqeaQpWh5ba8zqmp2MxCU=
953953
github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d h1:qSmEGTgjkESUX5kPMSGJ4pcBUtYVDdkNzMrjQyvRvp0=
954954
github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d/go.mod h1:x7SghIWwLVcJObXbjK7S2ENsT1cAcdJcPl7dRaSFog0=
955955
github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d h1:hTRDIpJ1FjS9ULJuEzu69n3qTgc18eI+ztw/pJv47hs=
@@ -1436,8 +1436,6 @@ go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
14361436
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
14371437
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
14381438
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
1439-
gocv.io/x/gocv v0.43.0 h1:PFNpRUcV8fgBRDbVHHN+4BDZjjPnVveo5N/+e15BTuA=
1440-
gocv.io/x/gocv v0.43.0/go.mod h1:zYdWMj29WAEznM3Y8NsU3A0TRq/wR/cy75jeUypThqU=
14411439
golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg=
14421440
golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
14431441
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=

internal/main.go

Lines changed: 4 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,13 @@ package main
22

33
import (
44
"fmt"
5-
"image"
6-
"image/color"
75

8-
"github.com/richelieu-yang/chimera/v3/src/ocr/gosseractKit"
9-
"gocv.io/x/gocv"
6+
"github.com/gogf/gf/v2/os/gfile"
107
)
118

12-
func convertToBinary(img image.Image, threshold uint8) *image.Gray {
13-
bounds := img.Bounds()
14-
binaryImg := image.NewGray(bounds)
15-
16-
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
17-
for x := bounds.Min.X; x < bounds.Max.X; x++ {
18-
oldColor := img.At(x, y)
19-
grayColor := color.GrayModel.Convert(oldColor).(color.Gray)
20-
21-
// 二值化: 高于阈值为白色,低于为黑色
22-
if grayColor.Y > threshold {
23-
binaryImg.Set(x, y, color.Gray{255})
24-
} else {
25-
binaryImg.Set(x, y, color.Gray{0})
26-
}
27-
}
28-
}
29-
30-
return binaryImg
31-
}
32-
33-
func preprocessForOCR(inputPath, outputPath string) {
34-
img := gocv.IMRead(inputPath, gocv.IMReadColor)
35-
defer img.Close()
36-
37-
// 1. 转灰度
38-
gray := gocv.NewMat()
39-
defer gray.Close()
40-
gocv.CvtColor(img, &gray, gocv.ColorBGRToGray)
41-
42-
// 2. 去噪
43-
denoised := gocv.NewMat()
44-
defer denoised.Close()
45-
gocv.GaussianBlur(gray, &denoised, image.Pt(3, 3), 0, 0, gocv.BorderDefault)
46-
47-
// 3. 二值化
48-
binary := gocv.NewMat()
49-
defer binary.Close()
50-
gocv.Threshold(denoised, &binary, 0, 255, gocv.ThresholdBinary|gocv.ThresholdOtsu)
51-
52-
// 4. 形态学操作(可选,去除小噪点)
53-
kernel := gocv.GetStructuringElement(gocv.MorphRect, image.Pt(2, 2))
54-
defer kernel.Close()
55-
gocv.MorphologyEx(binary, &binary, gocv.MorphClose, kernel)
56-
57-
gocv.IMWrite(outputPath, binary)
58-
}
59-
609
func main() {
61-
//file, _ := os.Open("/Users/richelieu/GolandProjects/chimera/screen_帆.png")
62-
//defer file.Close()
63-
//
64-
//img, _, _ := image.Decode(file)
65-
//
66-
//// 阈值128,可根据图片调整
67-
//binaryImg := convertToBinary(img, 128)
68-
//
69-
//outFile, _ := os.Create("output_binary.png")
70-
//defer outFile.Close()
71-
//
72-
//png.Encode(outFile, binaryImg)
73-
74-
//preprocessForOCR("/Users/richelieu/GolandProjects/chimera/screen_帆.png", "output_binary.png")
75-
//preprocessForOCR("/Users/richelieu/GolandProjects/chimera/screen_帆.png", "output_binary.png")
10+
//err := gfile.RemoveFile("/Users/richelieu/Desktop/111.png")
11+
err := gfile.RemoveAll("/Users/richelieu/Desktop/222.png")
7612

77-
fmt.Println(gosseractKit.GertText("/Users/richelieu/GolandProjects/chimera/screen_帆.png"))
13+
fmt.Println(err)
7814
}

src/component/mq/pulsarKit/verify.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package pulsarKit
33
import (
44
"context"
55
"fmt"
6+
"time"
7+
68
"github.com/apache/pulsar-client-go/pulsar"
79
"github.com/richelieu-yang/chimera/v3/src/core/conditionKit"
810
"github.com/richelieu-yang/chimera/v3/src/core/errorKit"
@@ -15,7 +17,6 @@ import (
1517
"github.com/richelieu-yang/chimera/v3/src/randomKit"
1618
"github.com/richelieu-yang/chimera/v3/src/time/timeKit"
1719
"github.com/sirupsen/logrus"
18-
"time"
1920
)
2021

2122
const (
@@ -61,12 +62,12 @@ func verify(config *VerifyConfig) (err error) {
6162
defer func() {
6263
if err == nil {
6364
// 验证成功的情况下,删掉客户端日志文件
64-
if err := fileKit.Remove(consumerLogPath); err != nil {
65+
if err := fileKit.RemoveAll(consumerLogPath); err != nil {
6566
logger.WithError(err).Error("Fail to delete consumerLogPath.")
6667
} else {
6768
logger.Info("Delete consumerLogPath.")
6869
}
69-
if err := fileKit.Remove(producerLogPath); err != nil {
70+
if err := fileKit.RemoveAll(producerLogPath); err != nil {
7071
logger.WithError(err).Error("Fail to delete producerLogPath.")
7172
} else {
7273
logger.Info("Delete producerLogPath.")

src/file/fileKit/operation.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package fileKit
22

33
import (
4-
"github.com/gogf/gf/v2/os/gfile"
54
"os"
65
"path/filepath"
76
"time"
7+
8+
"github.com/gogf/gf/v2/os/gfile"
89
)
910

1011
var (
@@ -14,14 +15,17 @@ var (
1415
// CutAndPaste 剪贴.
1516
CutAndPaste func(src string, dst string) (err error) = gfile.Move
1617

17-
// Remove 删除文件(或目录).
18+
// RemoveFile 删除文件.
19+
RemoveFile func(path string) (err error) = gfile.RemoveFile
20+
21+
// RemoveAll 删除文件(或目录).
1822
/*
1923
PS: 如果是目录且内部有文件或目录,也会一并删除.
2024
*/
21-
Remove func(path string) (err error) = gfile.Remove
25+
RemoveAll func(path string) (err error) = gfile.RemoveAll
2226

2327
// Delete 删除文件(或目录).
24-
Delete func(path string) (err error) = Remove
28+
Delete func(path string) (err error) = RemoveAll
2529

2630
// Truncate 更改文件大小的函数.
2731
/*
@@ -57,7 +61,7 @@ func EmptyDir(dirPath string) error {
5761
}
5862
for _, dirEntry := range dirEntries {
5963
path := filepath.Join(dirPath, dirEntry.Name())
60-
if err := Remove(path); err != nil {
64+
if err := RemoveAll(path); err != nil {
6165
return err
6266
}
6367
}

src/file/fileKit/operation_open.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package fileKit
22

33
import (
4+
"os"
5+
46
"github.com/gogf/gf/v2/os/gfile"
57
"github.com/richelieu-yang/chimera/v3/src/core/strKit"
6-
"os"
78
)
89

910
var (

src/image/imageKit/base64.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package imageKit
22

33
import (
44
"fmt"
5+
"os"
6+
"regexp"
7+
58
"github.com/richelieu-yang/chimera/v3/src/component/web/http_client/httpClientKit"
69
"github.com/richelieu-yang/chimera/v3/src/core/errorKit"
710
"github.com/richelieu-yang/chimera/v3/src/crypto/base64Kit"
811
"github.com/richelieu-yang/chimera/v3/src/file/fileKit"
9-
"os"
10-
"regexp"
1112
)
1213

1314
// GetImageBase64 (硬盘上的)图片 => base64字符串

src/image/imageKit/decode.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package imageKit
22

33
import (
44
"bytes"
5-
"github.com/richelieu-yang/chimera/v3/src/core/sliceKit"
6-
"github.com/richelieu-yang/chimera/v3/src/file/fileKit"
75
"image"
86
"io"
97
"os"
8+
9+
"github.com/richelieu-yang/chimera/v3/src/core/sliceKit"
10+
"github.com/richelieu-yang/chimera/v3/src/file/fileKit"
1011
)
1112

1213
// Decode 解码图片(部分特殊格式不支持; path => image.Image).

src/image/imageKit/format_bmp.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package imageKit
22

33
import (
4+
"os"
5+
46
"github.com/richelieu-yang/chimera/v3/src/file/fileKit"
57
"golang.org/x/image/bmp"
6-
"os"
78
)
89

910
// ToBmp 将图片格式转换为".bmp".

src/image/imageKit/format_jpeg.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package imageKit
22

33
import (
4-
"github.com/richelieu-yang/chimera/v3/src/file/fileKit"
54
"image"
65
"image/color"
76
"image/draw"
87
"image/jpeg"
98
"os"
9+
10+
"github.com/richelieu-yang/chimera/v3/src/file/fileKit"
1011
)
1112

1213
// ToJpeg 将图片格式转换为".jpg"(||".jpeg").

0 commit comments

Comments
 (0)