Skip to content

Commit

Permalink
3.0.0-betaに対応したサンプルアプリ
Browse files Browse the repository at this point in the history
  • Loading branch information
kadu-v committed May 17, 2024
0 parents commit 7787e74
Show file tree
Hide file tree
Showing 627 changed files with 6,191 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

.DS_Store
709 changes: 709 additions & 0 deletions EdgeOCRSample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F9CE84802B873BA8002BE6C8"
BuildableName = "EdgeOCRSample.app"
BlueprintName = "EdgeOCRSample"
ReferencedContainer = "container:EdgeOCRSample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F9CE84802B873BA8002BE6C8"
BuildableName = "EdgeOCRSample.app"
BlueprintName = "EdgeOCRSample"
ReferencedContainer = "container:EdgeOCRSample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F9CE84802B873BA8002BE6C8"
BuildableName = "EdgeOCRSample.app"
BlueprintName = "EdgeOCRSample"
ReferencedContainer = "container:EdgeOCRSample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
13 changes: 13 additions & 0 deletions EdgeOCRSample/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions EdgeOCRSample/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "sample_barcode.jpeg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions EdgeOCRSample/Assets.xcassets/sample_text.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "sample_text2.jpeg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions EdgeOCRSample/EdgeOCRSample.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
17 changes: 17 additions & 0 deletions EdgeOCRSample/EdgeOCRSample.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// EdgeOCRSampleApp.swift
// EdgeOCRSample
//
// Created by kikemori on 2024/02/22.
//

import SwiftUI

@main
struct EdgeOCRSample: App {
var body: some Scene {
WindowGroup {
MainView()
}
}
}
30 changes: 30 additions & 0 deletions EdgeOCRSample/Extensions/CALayer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// CALayer.swift
// EdgeOCRSample
//
// Created by kikemori on 2024/05/16.
//

import AVFoundation
import UIKit

extension CALayer {
func addCenterPoint(color: CGColor, radius: CGFloat) {
// CALayerの中心座標を取得します
let centerX = self.bounds.midX
let centerY = self.bounds.midY

// 点の描画
let dotLayer = CAShapeLayer()
dotLayer.path = UIBezierPath(
arcCenter: CGPoint(x: centerX, y: centerY),
radius: radius,
startAngle: 0,
endAngle: CGFloat(Double.pi * 2),
clockwise: true).cgPath
dotLayer.fillColor = color

// CALayerに点を追加します
self.addSublayer(dotLayer)
}
}
57 changes: 57 additions & 0 deletions EdgeOCRSample/Extensions/UIImage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// UIImage.swift
// EdgeOCRSample
//
// Created by kikemori on 2024/04/16.
//

import AVFoundation
import UIKit

extension UIImage {
func drawBoundingBoxes(
boundingBoxes: [CGRect],
texts: [String],
textColor: UIColor,
boxColor: UIColor
) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, scale)
defer { UIGraphicsEndImageContext() }

draw(at: .zero)
let imageLength = self.size.width > self.size.height ? self.size.width : self.size.height
let fontSize = imageLength * 0.03

for (index, boundingBox) in boundingBoxes.enumerated() {
let detectionResult = texts[index]
let context = UIGraphicsGetCurrentContext()
context?.setStrokeColor(UIColor.green.cgColor)
context?.setLineWidth(5.0)
context?.addRect(boundingBox)
context?.strokePath()

let textFontAttributes: [NSAttributedString.Key: Any] = [
NSAttributedString.Key.font: UIFont.systemFont(ofSize: fontSize),
NSAttributedString.Key.foregroundColor: textColor,
NSAttributedString.Key.backgroundColor: boxColor
]
let detectionText = NSAttributedString(string: detectionResult, attributes: textFontAttributes)
detectionText.draw(at: CGPoint(x: boundingBox.origin.x, y: boundingBox.origin.y))
}

return UIGraphicsGetImageFromCurrentImageContext()
}

func fixImageRotation() -> UIImage {
if self.imageOrientation != .up {
UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale)
self.draw(in: CGRect(origin: .zero, size: self.size))
if let fixedImage = UIGraphicsGetImageFromCurrentImageContext() {
UIGraphicsEndImageContext()
return fixedImage
}
UIGraphicsEndImageContext()
}
return self
}
}
Loading

0 comments on commit 7787e74

Please sign in to comment.