Comments (3)
I tried to train the network by myself. Here is what I have tried. I transformed the first image by -10 degrees. Then applied CISpotColor
filter to turn yellow-green color to black and rest to white. Then I used extractBlobs function. However it only found 5 blobs instead of 6. I checked blobs and found out that 4th blob is qd
. Since my image is fixed width, what is the part that I should change to correctly extract the blobs and train the network? Here is code that I use for image filters. I will really appreciate if you can help me out to solve this OCR problem.
let firstImage = transformImage("original.jpg")
let secondImage = myFilter(firstImage)
let blobs = ocrInstance.extractBlobs(secondImage)
func transformImage(imagename:String)->CIImage {
let degreesToRadians: (CGFloat) -> CGFloat = {
return $0 / 180.0 * CGFloat(M_PI)
}
let imagex = CIImage(image: UIImage(named: imagename)!)!
let transform = CIFilter(name:"CIAffineTransform")!
transform.setValue(imagex, forKey: kCIInputImageKey)
let rotation = NSValue(CGAffineTransform: CGAffineTransformMakeRotation(degreesToRadians(-10)))
transform.setValue(rotation, forKey: "inputTransform")
return transform.outputImage!
}
func myFilter(inputImage:CIImage) ->UIImage? {
self.context = CIContext(options: nil)
let centerColor1 = CIColor.init(color: UIColor.blackColor())
let replacementColor1 = CIColor.init(color: UIColor.whiteColor())
let centerColor2 = CIColor.init(color: UIColor.blueColor())
let replacementColor2 = CIColor.init(color: UIColor.whiteColor())
let centerColor3 = CIColor.init(color: UIColor(red: 0.75, green: 0.87, blue: 0.33, alpha: 1))
let replacementColor3 = CIColor.init(color: UIColor.blackColor())
let closeness1:Float = 0
let contrast1:Float = 0
let closeness2:Float = 0
let contrast2:Float = 0
let closeness3:Float = 0.5
let contrast3:Float = 1
let parameters : CIParameters = [
"inputCenterColor1":centerColor1,
"inputReplacementColor1":replacementColor1,
"inputCloseness1":closeness1,
"inputContrast1":contrast1,
"inputCenterColor2":centerColor2,
"inputReplacementColor2":replacementColor2,
"inputCloseness2":closeness2,
"inputContrast2":contrast2,
"inputCenterColor3":centerColor3,
"inputReplacementColor3":replacementColor3,
"inputCloseness3":closeness3,
"inputContrast3":contrast3,
kCIInputImageKey: inputImage
]
let colorSpot = CIFilter(name:"CISpotColor", withInputParameters: parameters)
if colorSpot == nil {
print("error filter")
return nil
}
self.tempModImage = colorSpot!.outputImage
let cgimg = context.createCGImage(self.tempModImage, fromRect: self.tempModImage .extent)
return UIImage(CGImage: cgimg)
}
from swiftocr.
Hi. I tried extractBlobs
with this image:
It extracted all blobs correctly after I applied the default preprocessing algorithm. You could try adding a thresholding filter at the and of your custom filter.
from swiftocr.
I could make it by changing let xMergeRadius:CGFloat = 0.5
However I still couldn't used your trainer to train the network.Then I used more than 100 samples to train the network. It finished around 1-2 minutes. It worked with 100% success rate. I don't know maybe I was lucky 😄 Thanks for your extractBlobs
code, it really helped.
from swiftocr.
Related Issues (20)
- Cannot Build SwiftOCR with Swift 4.2 HOT 4
- Cannot build for macOS using CocoaPods
- How to install Swift OCR using Swift Package Manager?
- Can't Invoke NSimage image in method SwiftOCRInstance.recognize! HOT 1
- Any Wrapper for another programming language?
- Doesn't work on Xcode 10.2
- Low accuracy HOT 1
- Update recognizableCharacters not working
- Fix for crash in multithreaded apps
- crashed in FFNN.swift at line 228 HOT 1
- support for Xcode 11 Beta HOT 2
- Can SwiftOCR detect any language text or just english language ?
- No Output String HOT 4
- Statement about accuracy
- please support swift5.0 HOT 11
- Carthage not working
- Not compatible with Xcode 12 beta5 HOT 4
- cocoapods install error. not search tag 1.2.1
- No such module 'GPUImage' HOT 1
- Can the ios.deployment_target be lowered to 11.0?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftocr.