-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gaoyi
committed
Oct 16, 2023
1 parent
5dbc014
commit 87bfd2b
Showing
8 changed files
with
241 additions
and
123 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
# swift_coco | ||
# swift_coco | ||
|
||
## Package used? | ||
swift package [SwiftyJson](https://swiftpackageindex.com/SwiftyJSON/SwiftyJSON) not compitable with Linux for now, so write entirely using swift native [JSONDecoder](https://developer.apple.com/documentation/foundation/jsondecoder). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,110 @@ | ||
protocol axera_shape { | ||
var shapeType : String { get } | ||
} | ||
struct axera_frame_frame: Codable { | ||
var imageUrl: String | ||
var frameIndex: Int? | ||
var valid: Bool | ||
var imageWidth: Int | ||
var imageHeight: Int | ||
var rotation: Double | ||
// deal with dynamic defined attr | ||
var attributes: [String: String]? | ||
|
||
struct axera_rect : Codable { | ||
var x : Int | ||
var y : Int | ||
var width : Int | ||
var height : Int | ||
var rotation : Int | ||
var points : [[String: Any]] | ||
enum CodingKeys: String, CodingKey { | ||
case imageUrl, frameIndex, valid, imageWidth, imageHeight, rotation | ||
case attributes | ||
} | ||
} | ||
|
||
struct axera_frame_frame : Codable { | ||
var frameIndex : Int | ||
var valid : Bool | ||
// TODO variable length attributes | ||
struct axera_frame: Codable { | ||
var camera: String | ||
var frames: [axera_frame_frame] | ||
} | ||
|
||
struct axera_frame : Codable { | ||
var camera : String | ||
var frames : [axera_frame_frame] | ||
} | ||
struct axera_camera_frame : Codable { | ||
var frameIndex : Int | ||
var isKeyFrame : Bool | ||
var shapeType : String | ||
// TODO : generic to deal with different shape | ||
var shape : axera_shape | ||
var order : Int | ||
var attributes : [String: Any] | ||
var isOCR : Bool | ||
var OCRText : String | ||
struct axera_camera_frame: Codable { | ||
var frameIndex: Int? | ||
var isKeyFrame: Bool? | ||
var shapeType: String? | ||
// TODO: enum to deal with different shape | ||
var shape: BaseShape? | ||
var order: Int? | ||
var attributes: [String: String]? | ||
var isOCR: Bool? | ||
var isFormula: Bool? | ||
var OCRText: String? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case shapeType | ||
case shape | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
shapeType = try container.decode(String.self, forKey: .shapeType) | ||
|
||
//print the type of BaseShape | ||
|
||
switch shapeType { | ||
// TODO | ||
case "rectangle": | ||
let rect = try container.decode(Rectangle.self, forKey: .shape) | ||
shape = .rectangle(rect) | ||
case "polygon": | ||
let poly = try container.decode(Polygon.self, forKey: .shape) | ||
shape = .polygon(poly) | ||
case "line": | ||
let line = try container.decode(Line.self, forKey: .shape) | ||
shape = .line(line) | ||
case "ellipse": | ||
let elli = try container.decode(Ellipse.self, forKey: .shape) | ||
shape = .ellipse(elli) | ||
case "dot": | ||
let dot = try container.decode(Dot.self, forKey: .shape) | ||
shape = .dot(dot) | ||
case "cuboid": | ||
let cub = try container.decode(Cuboid.self, forKey: .shape) | ||
shape = .cuboid(cub) | ||
case "l_shape": | ||
let l_shape = try container.decode(L_shape.self, forKey: .shape) | ||
shape = .l_shape(l_shape) | ||
case "grid": | ||
let grid = try container.decode(Grid.self, forKey: .shape) | ||
shape = .grid(grid) | ||
default: | ||
shape = nil | ||
} | ||
} | ||
} | ||
|
||
struct axera_camera : Codable { | ||
var camera : String | ||
var frames : [axera_camera_frame] | ||
struct axera_camera: Codable { | ||
var camera: String | ||
var frames: [axera_camera_frame] | ||
} | ||
|
||
struct axera_child : Codable { | ||
var id : String | ||
var name : String | ||
var number : Int | ||
var cameras : [axera_camera] | ||
struct axera_child: Codable { | ||
var id: String | ||
var name: String | ||
var displayName: String | ||
var displayColor: String | ||
var number: Int | ||
var cameras: [axera_camera] | ||
} | ||
|
||
struct axera_instance : Codable { | ||
var id : String | ||
var category : String | ||
var number : Int | ||
var attributes : [String: Any] | ||
var children : [axera_child] | ||
struct axera_instance: Codable { | ||
var id: String | ||
var category: String | ||
var categoryName: String | ||
var number: Int | ||
var attributes: [String: String]? | ||
var children: [axera_child] | ||
} | ||
|
||
// defines axera shapes | ||
|
||
struct axera_img_anno : Codable { | ||
var auditId : String | ||
var instances : [axera_instance] | ||
var frames : [axera_frame] | ||
var statistics : String | ||
} | ||
struct axera_img_anno: Codable { | ||
var auditId: String | ||
var instances: [axera_instance] | ||
var frames: [axera_frame] | ||
var relationships: [[String: String]] | ||
var attributes: [String: String]? | ||
var statistics: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
enum BaseShape: Codable { | ||
case rectangle(Rectangle) | ||
case polygon(Polygon) | ||
case line(Line) | ||
case ellipse(Ellipse) | ||
case dot(Dot) | ||
case cuboid(Cuboid) | ||
case l_shape(L_shape) | ||
case grid(Grid) | ||
} | ||
|
||
struct Rectangle_points: Codable { | ||
var x: Double | ||
var y: Double | ||
} | ||
|
||
struct Rectangle: Codable { | ||
var x: Double | ||
var y: Double | ||
var width: Double | ||
var height: Double | ||
var area: Double | ||
var rotation: Double | ||
var points: [Rectangle_points] | ||
var center: Double? | ||
} | ||
|
||
struct UserData: Codable { | ||
var start: Bool? | ||
var end: Bool? | ||
} | ||
|
||
struct Polygon_points: Codable { | ||
var x: Double | ||
var y: Double | ||
var userData: UserData? | ||
} | ||
|
||
struct Polygon: Codable { | ||
var points: [Polygon_points] | ||
} | ||
|
||
struct Line: Codable { | ||
var points: [Polygon_points] | ||
} | ||
|
||
struct Ellipse: Codable { | ||
var x: Double | ||
var y: Double | ||
var halfWidth: Double | ||
var halfHeight: Double | ||
} | ||
|
||
struct Dot: Codable { | ||
var x: Double | ||
var y: Double | ||
} | ||
|
||
struct CuboidFrontBack: Codable { | ||
var x: Double | ||
var y: Double | ||
var width: Double | ||
var height: Double | ||
} | ||
|
||
struct Cuboid: Codable { | ||
var front: CuboidFrontBack | ||
var back: CuboidFrontBack | ||
} | ||
|
||
struct L_shape: Codable { | ||
var front: CuboidFrontBack | ||
var sidePoints: [Rectangle_points] | ||
var center: Double | ||
} | ||
|
||
struct Grid: Codable { | ||
var cols: [[String: Double]] | ||
var rows: [[String: Double]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.