papers's People
papers's Issues
No dismiss option in sheet on iPad and Catalyst
No way to dismiss the sort sheet on macOS, swipe gestures not working
Extracting Answers
Markscheme format for pre-2017 papers is different, and needs a different function to extract answers
Extracting Questions
Unable to correctly separate paper into questions and their containing pages.
SearchBar in NavigationView
SearchBar shows up on every page instead of the page it was placed in.
Cropping Image
Below is some example code for a visual preview of snapshots of pages from a test pdf, cropped to isolate the question numbers, which are then to be detected using VisionKit:
struct TestCrop: View {
let pdf = PDFDocument(url: URL(fileURLWithPath: Bundle.main.path(forResource: "9701_m20_qp_42", ofType: "pdf")!))!
var body: some View {
ScrollView {
VStack {
ForEach(1..<(pdf.pageCount - 1)){ i in
Image(cgImage: pdf.page(at: i)!.snapshot().cgImage!.cropping(to: CGRect(origin: CGPoint(x: 50, y: 0), size: CGSize(width: 100, height: 1000)))!)
.resizable()
.border(Color.black)
.scaleEffect(0.10, anchor: .center)
.scaledToFill()
}
}
}
}
}
When the underlying values for the CGRect cropping the image are changed to further isolate the number, VisionKit seems to fail at recognising it, even though language correction is disabled, and numbers are specifically marked as custom words.
recognizeTextRequest.usesLanguageCorrection = false
recognizeTextRequest.customWords = Array(1..<10).map { "\($0)" }
Furthermore, in tests with different sized phones, there are cases when Vision fails to detect the questions accurately, even though the screen size of the phone is not used as an argument anywhere.
Below is the full code for the VisionKit helper function being called to detect text:
func recogniseText(from image: CGImage) -> String {
var recognizedText = ""
let recognizeTextRequest = VNRecognizeTextRequest { (request, error) in
guard error == nil else { return }
guard let observations = request.results as? [VNRecognizedTextObservation] else { return }
let maximumRecognitionCandidates = 1
for observation in observations {
guard let candidate = observation.topCandidates(maximumRecognitionCandidates).first else { continue }
recognizedText = candidate.string
}
}
recognizeTextRequest.recognitionLevel = .accurate
recognizeTextRequest.usesLanguageCorrection = false
recognizeTextRequest.customWords = Array(1..<10).map { "\($0)" }
recognizeTextRequest.revision = VNRecognizeTextRequestRevision2
let requestHandler = VNImageRequestHandler(cgImage: image, options: [:])
try? requestHandler.perform([recognizeTextRequest])
return recognizedText
}
Change page classification algorithm
Use attributed text to get question numbers instead of image-cropping
Reduce CambridgeQuestionPaper and CambridgeMarkscheme into CambridgePaper
Use one model for all papers, sort them further by their properties.
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.