cronz / cnlite_cs Goto Github PK
View Code? Open in Web Editor NEWcnlite is a c# library to do chinese ocr based on project chineseocr_lite
License: Apache License 2.0
cnlite is a c# library to do chinese ocr based on project chineseocr_lite
License: Apache License 2.0
private Tensor GetInputs(string imageFilePath, Mat rgbMat, out int new_h, out int new_w)
{
// Read image
Mat imageMat = CvInvoke.Imread(imageFilePath, ImreadModes.Color);
CvInvoke.CvtColor(imageMat, rgbMat, ColorConversion.Bgr2Rgb);
imageMat.Dispose();
//取图片最小的边做为短边
int short_size = rgbMat.Height < rgbMat.Width ? rgbMat.Height : rgbMat.Width;
//测试发现如果短边小于96,会造成识别不出来或者识别不完全,要保证短边不小于96
if (short_size < 96)
{
short_size = 96;
}
//短边 取整为32的倍数
short_size = 32 * (short_size / 32);
double scale_h = 0, tar_w = 0, scale_w = 0, tar_h = 0;
if (rgbMat.Height < rgbMat.Width)
{
scale_h = short_size * 1.0 / rgbMat.Height;
tar_w = rgbMat.Width * scale_h * 1.0;
tar_w = tar_w - tar_w % 32;
tar_w = Math.Max(32, tar_w);
scale_w = tar_w / rgbMat.Width;
}
else
{
scale_w = short_size * 1.0 / rgbMat.Width;
tar_h = rgbMat.Height * scale_w * 1.0;
tar_h = tar_h - tar_h % 32;
tar_h = Math.Max(32, tar_h);
scale_h = tar_h / rgbMat.Height;
}
new_h = (int)(scale_h * rgbMat.Height);
new_w = (int)(scale_w * rgbMat.Width);
Mat imgResized = new Mat(new_h, new_w, DepthType.Cv32F, 3);
CvInvoke.Resize(rgbMat, imgResized, new Size(new_w, new_h));
return GetTensorInputFromImg(imgResized);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.