测试image
This commit is contained in:
parent
04faa3d95b
commit
bd241447c6
BIN
csv/csv.dll
BIN
csv/csv.dll
Binary file not shown.
@ -133,7 +133,6 @@ func NewCSVManager(config ManagerConfig) *CSVManager {
|
|||||||
if config.MaxOpenFiles <= 0 {
|
if config.MaxOpenFiles <= 0 {
|
||||||
config.MaxOpenFiles = DefaultConfig.MaxOpenFiles
|
config.MaxOpenFiles = DefaultConfig.MaxOpenFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
return &CSVManager{
|
return &CSVManager{
|
||||||
handles: sync.Map{},
|
handles: sync.Map{},
|
||||||
nextHandle: 1,
|
nextHandle: 1,
|
||||||
|
|||||||
102
csv/csv.h
102
csv/csv.h
@ -1,102 +0,0 @@
|
|||||||
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
|
||||||
|
|
||||||
/* package command-line-arguments */
|
|
||||||
|
|
||||||
|
|
||||||
#line 1 "cgo-builtin-export-prolog"
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
||||||
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
||||||
|
|
||||||
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
||||||
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
||||||
extern size_t _GoStringLen(_GoString_ s);
|
|
||||||
extern const char *_GoStringPtr(_GoString_ s);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Start of preamble from import "C" comments. */
|
|
||||||
|
|
||||||
|
|
||||||
#line 3 "csv.go"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#line 1 "cgo-generated-wrapper"
|
|
||||||
|
|
||||||
|
|
||||||
/* End of preamble from import "C" comments. */
|
|
||||||
|
|
||||||
|
|
||||||
/* Start of boilerplate cgo prologue. */
|
|
||||||
#line 1 "cgo-gcc-export-header-prolog"
|
|
||||||
|
|
||||||
#ifndef GO_CGO_PROLOGUE_H
|
|
||||||
#define GO_CGO_PROLOGUE_H
|
|
||||||
|
|
||||||
typedef signed char GoInt8;
|
|
||||||
typedef unsigned char GoUint8;
|
|
||||||
typedef short GoInt16;
|
|
||||||
typedef unsigned short GoUint16;
|
|
||||||
typedef int GoInt32;
|
|
||||||
typedef unsigned int GoUint32;
|
|
||||||
typedef long long GoInt64;
|
|
||||||
typedef unsigned long long GoUint64;
|
|
||||||
typedef GoInt64 GoInt;
|
|
||||||
typedef GoUint64 GoUint;
|
|
||||||
typedef size_t GoUintptr;
|
|
||||||
typedef float GoFloat32;
|
|
||||||
typedef double GoFloat64;
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#if !defined(__cplusplus) || _MSVC_LANG <= 201402L
|
|
||||||
#include <complex.h>
|
|
||||||
typedef _Fcomplex GoComplex64;
|
|
||||||
typedef _Dcomplex GoComplex128;
|
|
||||||
#else
|
|
||||||
#include <complex>
|
|
||||||
typedef std::complex<float> GoComplex64;
|
|
||||||
typedef std::complex<double> GoComplex128;
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
typedef float _Complex GoComplex64;
|
|
||||||
typedef double _Complex GoComplex128;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
static assertion to make sure the file is being used on architecture
|
|
||||||
at least with matching size of GoInt.
|
|
||||||
*/
|
|
||||||
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
||||||
|
|
||||||
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
||||||
typedef _GoString_ GoString;
|
|
||||||
#endif
|
|
||||||
typedef void *GoMap;
|
|
||||||
typedef void *GoChan;
|
|
||||||
typedef struct { void *t; void *v; } GoInterface;
|
|
||||||
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* End of boilerplate cgo prologue. */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// ===================== C 函数导入 ==================
|
|
||||||
// OpenCSVFile 打开/创建CSV文件
|
|
||||||
//
|
|
||||||
extern __declspec(dllexport) char* OpenCSVFile(char* filename, char delimiter, int hasHeader);
|
|
||||||
|
|
||||||
// UpdateCSVRowSafe 修改csv文件行数据
|
|
||||||
//
|
|
||||||
extern __declspec(dllexport) char* UpdateCSVRowSafe(long long int handleID, int rowNum, char* newRow);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
"isbn","价格","库存","日志","三方平台id"
|
|
||||||
"9787107267505","30.80","1","上传成功","877133619369"
|
|
||||||
"9787200066883","23.17","1","上传成功","877132920079"
|
|
||||||
"9787115524539","8.87","","调用过于频繁,请调整调用频率",""
|
|
||||||
"9787810791373","32.02","","调用过于频繁,请调整调用频率",""
|
|
||||||
"9787548745600","151.30","","商品价格不在设置的价格区间",""
|
|
||||||
"9787111546955","8.47","","商品信息中包含违规内容",""
|
|
||||||
"9787303284382","62.76","1","上传成功","877133371509"
|
|
||||||
|
@ -87,7 +87,7 @@ type Statistics struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewESClient 初始化 ES 客户端
|
// NewESClient 初始化 ES 客户端
|
||||||
// 说明:与 main(2).go 保持一致的连接方式(禁用证书校验、设置超时和连接池参数)
|
// 说明:保持一致的连接方式(禁用证书校验、设置超时和连接池参数)
|
||||||
func NewESClient(addresses []string, username, password string) (*ESClient, error) {
|
func NewESClient(addresses []string, username, password string) (*ESClient, error) {
|
||||||
cfg := elasticsearch.Config{
|
cfg := elasticsearch.Config{
|
||||||
Addresses: addresses,
|
Addresses: addresses,
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import (
|
|||||||
type imageDLL struct {
|
type imageDLL struct {
|
||||||
dll *syscall.DLL
|
dll *syscall.DLL
|
||||||
processImage *syscall.Proc
|
processImage *syscall.Proc
|
||||||
|
createWhiteBottomCenteredImage *syscall.Proc
|
||||||
freeCString *syscall.Proc
|
freeCString *syscall.Proc
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ func InitImageDll() (*imageDLL, error) {
|
|||||||
return &imageDLL{
|
return &imageDLL{
|
||||||
dll: dll,
|
dll: dll,
|
||||||
processImage: dll.MustFindProc("ProcessImage"),
|
processImage: dll.MustFindProc("ProcessImage"),
|
||||||
|
createWhiteBottomCenteredImage: dll.MustFindProc("CreateWhiteBottomCenteredImage"),
|
||||||
freeCString: dll.MustFindProc("FreeCString"),
|
freeCString: dll.MustFindProc("FreeCString"),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -44,6 +46,21 @@ func (m *imageDLL) ProcessImage(config *Config) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *imageDLL) CreateWhiteBottomCenteredImage(config *Config, w int, h int) (string, error) {
|
||||||
|
proc, err2 := m.dll.FindProc("CreateWhiteBottomCenteredImage")
|
||||||
|
if err2 != nil {
|
||||||
|
return "", err2
|
||||||
|
}
|
||||||
|
marshal, err := json.Marshal(config)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("json转换失败: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fromString, _ := syscall.BytePtrFromString(string(marshal))
|
||||||
|
info, _, _ := proc.Call(uintptr(unsafe.Pointer(fromString)), uintptr(w), uintptr(h))
|
||||||
|
return cStr(info), nil
|
||||||
|
}
|
||||||
|
|
||||||
// cStr 将 C 字符串指针转换为 Go 字符串
|
// cStr 将 C 字符串指针转换为 Go 字符串
|
||||||
func cStr(ptr uintptr) string {
|
func cStr(ptr uintptr) string {
|
||||||
if ptr == 0 {
|
if ptr == 0 {
|
||||||
@ -61,27 +78,32 @@ func cStr(ptr uintptr) string {
|
|||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
func main() {
|
||||||
//func main() {
|
|
||||||
//
|
config := &Config{
|
||||||
// config := &Config{
|
OutputDir: "D:\\isbn_images\\result", // 输出根目录
|
||||||
// InputDir: "D:\\www\\wwwroot\\imageTool\\img\\image", // 输入图片目录
|
FileName: "D:\\isbn_images\\result\\9771671688095.jpg",
|
||||||
// OutputDir: "D:\\isbn_images\\result", // 输出根目录
|
MatchDir: "matched", // 满足条件的图片目录
|
||||||
// FileName: "D:\\isbn_images\\result\\9771671688095.jpg",
|
UnmatchDir: "unmatched", // 不满足条件的图片目录
|
||||||
// MatchDir: "matched", // 满足条件的图片目录
|
WhiteDir: "white",
|
||||||
// UnmatchDir: "unmatched", // 不满足条件的图片目录
|
EqualHeightDir: "equalHeight",
|
||||||
// EqualHeightDir: "equalHeight",
|
MinWhitePct: 0.1, // 纯白占比下限 10%
|
||||||
// MinWhitePct: 0.1, // 纯白占比下限 10%
|
MaxWhitePct: 0.65, // 纯白占比上限 90%
|
||||||
// MaxWhitePct: 0.65, // 纯白占比上限 90%
|
Extensions: []string{"jpg", "jpeg", "png", "gif", "bmp", "webp"},
|
||||||
// Extensions: []string{"jpg", "jpeg", "png", "gif", "bmp", "webp"},
|
}
|
||||||
// }
|
|
||||||
//
|
dll, err := InitImageDll()
|
||||||
// dll, err := InitImageDll()
|
if err != nil {
|
||||||
// if err != nil {
|
fmt.Println(err)
|
||||||
// fmt.Println(err)
|
}
|
||||||
// }
|
//err = dll.ProcessImage(config)
|
||||||
// err = dll.ProcessImage(config)
|
//if err != nil {
|
||||||
// if err != nil {
|
// fmt.Println(err)
|
||||||
// fmt.Println(err)
|
//}
|
||||||
// }
|
|
||||||
//}
|
image, err := dll.CreateWhiteBottomCenteredImage(config, 800, 800)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println(image)
|
||||||
|
}
|
||||||
|
|||||||
@ -1,43 +1,41 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
//func main() {
|
||||||
|
// // ==================== 在这里设置你的参数 ====================
|
||||||
func main() {
|
// config := &Config{
|
||||||
// ==================== 在这里设置你的参数 ====================
|
// OutputDir: "D:\\isbn_images\\result", // 输出根目录
|
||||||
config := &Config{
|
// FileName: "D:\\isbn_images\\result\\9771671688095.jpg",
|
||||||
OutputDir: "D:\\isbn_images\\result", // 输出根目录
|
// MatchDir: "matched", // 满足条件的图片目录
|
||||||
FileName: "D:\\isbn_images\\result\\9771671688095.jpg",
|
// UnmatchDir: "unmatched", // 不满足条件的图片目录
|
||||||
MatchDir: "matched", // 满足条件的图片目录
|
// EqualHeightDir: "equalHeight",
|
||||||
UnmatchDir: "unmatched", // 不满足条件的图片目录
|
// WhiteDir: "white",
|
||||||
EqualHeightDir: "equalHeight",
|
// WhiteBorderPngDir: "whiteBorderPng",
|
||||||
WhiteDir: "white",
|
// MinWhitePct: 0.1, // 纯白占比下限 10%
|
||||||
WhiteBorderPngDir: "whiteBorderPng",
|
// MaxWhitePct: 0.65, // 纯白占比上限 90%
|
||||||
MinWhitePct: 0.1, // 纯白占比下限 10%
|
// Extensions: []string{"jpg", "jpeg", "png", "gif", "bmp", "webp"},
|
||||||
MaxWhitePct: 0.65, // 纯白占比上限 90%
|
// }
|
||||||
Extensions: []string{"jpg", "jpeg", "png", "gif", "bmp", "webp"},
|
//
|
||||||
}
|
// //err := processImage(config)
|
||||||
|
// //if err != nil {
|
||||||
//err := processImage(config)
|
// // fmt.Println(err)
|
||||||
//if err != nil {
|
// //}
|
||||||
// fmt.Println(err)
|
// //
|
||||||
//}
|
// //file, err := resizeToHeightQuality(config, 700)
|
||||||
//
|
// //if err != nil {
|
||||||
//file, err := resizeToHeightQuality(config, 700)
|
// // fmt.Println(err)
|
||||||
//if err != nil {
|
// //}
|
||||||
// fmt.Println(err)
|
// //fmt.Println(file)
|
||||||
//}
|
// //config.FileName = file
|
||||||
//fmt.Println(file)
|
// //fmt.Println(config)
|
||||||
//config.FileName = file
|
// //file1, err := createWhiteBottomCenteredImage(config, 800, 800)
|
||||||
//fmt.Println(config)
|
// //if err != nil {
|
||||||
//file1, err := createWhiteBottomCenteredImage(config, 800, 800)
|
// // fmt.Println(err)
|
||||||
//if err != nil {
|
// //}
|
||||||
// fmt.Println(err)
|
// //fmt.Println(file1)
|
||||||
//}
|
//
|
||||||
//fmt.Println(file1)
|
// png, err := removeWhiteBorderAndPNG(config)
|
||||||
|
// if err != nil {
|
||||||
png, err := removeWhiteBorderAndPNG(config)
|
// fmt.Println(err)
|
||||||
if err != nil {
|
// }
|
||||||
fmt.Println(err)
|
// fmt.Println(png)
|
||||||
}
|
//}
|
||||||
fmt.Println(png)
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user