-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancements for image scanning #29
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great enhancements! Some minor comments and questions, but looks great!
scanline/IntExtensions.swift
Outdated
// scanline | ||
// | ||
// Created by Florian Dreier on 12/30/19. | ||
// Copyright © 2019 Scott J. Kleper. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should probably go and remove this everywhere, maybe just pointing to the LICENSE file. Feel free to omit this line. My name doesn't need to be on everything!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just the default header that XCode generated. I replaced the headers now with
//
// This code is part of scanline and published under MIT license.
//
WDYT?
scanline/ArrayExtensions.swift
Outdated
|
||
extension Array where Iterator.Element == Int { | ||
|
||
func doesValueAroundIndexPassFivePercent(index: Int, total: Int) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment for this function would be helpful. I'm not 100% sure I get what it's doing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't like this method either. Took this as a chance to refactor the code so that the method is no longer needed. Hope this makes things clearer.
@@ -0,0 +1,18 @@ | |||
// | |||
// UIImageExtensions.swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong filename :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
import Foundation | ||
|
||
/// Describes insets that can be applied to a rectangle. | ||
struct Insets { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this just be UIEdgeInsets
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS UIEdgeInsets is only part of UIKit, which is not linked against scanline as it is a command line application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right...
Thanks for your review! |
Now opens all scanned images in a single window
@@ -95,7 +91,7 @@ + (NSDictionary*)configOptions | |||
ScanlineConfigOptionArea: @{ | |||
@"synonyms": @[@"size"], | |||
@"type": @"string", | |||
@"description": @"Specify the size of the area that should be scanned in cm (Default is the whole flatbed scan area)" | |||
@"description": @"Specify the size of the area that should be scanned in cm. Forat is <width>x<height>, e.g. 20x20 (Default is the whole flatbed scan area)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*Format :)
guard error == nil else { | ||
logger.log("Error received while attempting to open a session with the scanner.") | ||
delegate?.scannerControllerDidFail(self) | ||
if(configuration.batchScan) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(configuration.batchScan) { | |
if configuration.batchScan { |
|
||
logger.log("Error received while attempting to close a session with the scanner.") | ||
delegate?.scannerControllerDidFail(self) | ||
if(configuration.batchScan) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(configuration.batchScan) { | |
if configuration.batchScan { |
@@ -8,7 +8,7 @@ | |||
|
|||
#import <XCTest/XCTest.h> | |||
|
|||
#import "ScanConfiguration.h" | |||
#import "../scanline/ScanConfiguration.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to get it to work by doing the following:
- Change to
#import "ScanConfiguration.h"
inScanConfigurationTests.m
- Remove everything except
ScanConfigurationTests.m
andScanConfiguration.m
from theCompile Sources
step - Remove
#import "scanline-Swift.h"
fromScanConfiguration.m
It's not ideal -- we shouldn't need any of the app source files in the test target -- but I'm not sure what the issue is right now with that.
import Foundation | ||
|
||
/// Describes insets that can be applied to a rectangle. | ||
struct Insets { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right...
|
||
init(fromString insets: String) { | ||
let insetValues = insets.split(separator: ":") | ||
self.init(left: Double(insetValues[0])!, top: Double(insetValues[1])!, right: Double(insetValues[2])!, bottom: Double(insetValues[1])!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to avoid the force unwraps here?
@@ -12,5 +12,3 @@ let appController = ScanlineAppController(arguments: CommandLine.arguments) | |||
appController.go() | |||
|
|||
CFRunLoopRun() | |||
|
|||
print("Done") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough...
Hey @klep, I noticed that this PR was last updated in 2020, but there was a recent v2.0 release this year. I'm not sure how many enhancements were made between v1.0 and v2.0, but I was wondering where that leaves this PR and its enhancements. Thank you! |
@rramphal It looks like there were some comments that were not addressed. These do look like worthy changes, but they'd have to be adapted for the newer version... |
Hi Scott,
Thanks for your work on this tool.
I found it very useful and a good starting point for my own needs. I'm currently digitalizing a bunch of old printed photos. To make this easier I added some enhancements to scanline that might also be useful for others.
Enhancements are:
Additionally I have done some refactorings/cleanup:
Let me know what you think 🙂
P.S. I would suggest to look at the changes commit by commit.