Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Commit 817730e

Browse files
committed
Correct the format.
1 parent 60a2aaf commit 817730e

30 files changed

+1240
-1109
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
- id: detect-private-key
1313
files: (?!.*tar.gz)^.*$
1414
- id: end-of-file-fixer
15-
files: \.md$
15+
files: \.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
1616
- id: trailing-whitespace
17-
files: \.md$
17+
files: \.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
1818
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
1919
sha: v1.0.1
2020
hooks:
2121
- id: forbid-crlf
22-
files: \.(md|c|cc|cxx|cpp|cu|h|hpp|hxx)$
22+
files: \.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
2323
- id: remove-crlf
24-
files: \.(md|c|cc|cxx|cpp|cu|h|hpp|hxx)$
24+
files: \.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
2525
- id: forbid-tabs
26-
files: \.(md|c|cc|cxx|cpp|cu|h|hpp|hxx)$
26+
files: \.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
2727
- id: remove-tabs
28-
files: \.(md|c|cc|cxx|cpp|cu|h|hpp|hxx)$
28+
files: \.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
2929
- repo: local
3030
hooks:
3131
- id: clang-format-with-version-check

Demo/iOS/AICamera/AICamera/AICamera-Bridging-Header.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//
2-
// Use this file to import your target's public headers that you would like to expose to Swift.
2+
// Use this file to import your target's public headers that you would like to
3+
// expose to Swift.
34
//
45

56
#import "ImageRecognizerPaddleWrapper.h"

Demo/iOS/AICamera/AICamera/AppDelegate.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4646

4747

4848
}
49-

Demo/iOS/AICamera/AICamera/ImageRecognizer.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ protocol ImageRecognizerDelegate {
1414
}
1515

1616
class ImageRecognizer {
17-
17+
1818
var imageRecognizer: ImageRecognizerPaddleWrapper?
19-
19+
2020
init(model: SSDModel) {
2121
imageRecognizer = ImageRecognizerPaddleWrapper(model: model.rawValue, withNormHeight: model.normDimension().0, withNormWidth: model.normDimension().1)
2222
}
23-
23+
2424
func inference(imageBuffer: UnsafeMutablePointer<UInt8>!, width: Int32, height: Int32, score: Float) -> NSMutableArray! {
25-
25+
2626
return imageRecognizer?.inference(imageBuffer, withHeight: height, withWidth: width, withFilterScore: score)
2727
}
28-
28+
2929
func release() {
3030
imageRecognizer?.destroy()
3131
}
32-
33-
}
32+
33+
}

Demo/iOS/AICamera/AICamera/ImageRecognizerPaddleWrapper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313

1414
@interface ImageRecognizerPaddleWrapper : NSObject
1515

16-
- (instancetype)initWithModel:(NSString*)modelFileName withNormHeight:(int)height withNormWidth:(int)width;
17-
- (NSMutableArray*)inference:(unsigned char *)pixels withHeight:(int)height withWidth:(int)width withFilterScore:(float) filterScore;
16+
- (instancetype)initWithModel:(NSString *)modelFileName
17+
withNormHeight:(int)height
18+
withNormWidth:(int)width;
19+
- (NSMutableArray *)inference:(unsigned char *)pixels
20+
withHeight:(int)height
21+
withWidth:(int)width
22+
withFilterScore:(float)filterScore;
1823
- (void)destroy;
1924

2025
@end

Demo/iOS/AICamera/AICamera/ImageRecognizerPaddleWrapper.mm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ - (instancetype)initWithModel:(NSString*)modelFileName withNormHeight:(int)heigh
3232
{
3333
int channel = 3;
3434
const std::vector<float> means({104, 117, 124});
35-
35+
3636
NSBundle* bundle = [NSBundle mainBundle];
3737
NSString* resourceDirectoryPath = [bundle bundlePath];
3838
NSString* path = [[resourceDirectoryPath stringByAppendingString:@"/"] stringByAppendingString:modelFileName];
39-
39+
4040
self->recognizer.init([path UTF8String], height, width, channel, means);
41-
41+
4242
}
4343
return self;
4444
}
@@ -48,25 +48,25 @@ - (NSMutableArray*)inference:(unsigned char *)pixels withHeight:(int)height with
4848
int channel = 4;
4949
image::Config config(image::kBGR, image::CLOCKWISE_R90);
5050
self->recognizer.infer(pixels, height, width, channel, config, result);
51-
51+
5252
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:result.height];
5353
int w = result.width;
54-
54+
5555
for (int i = 0; i < result.height; i++) {
5656
float score = result.data[i * w + 2];
5757
if (score < filterScore) continue;
58-
58+
5959
SSDData *ssdData = [[SSDData alloc] init];
6060
ssdData.label = kLabels[(int) result.data[i * w + 1]];
6161
ssdData.accuracy = score;
6262
ssdData.xmin = result.data[i * w + 3];
6363
ssdData.ymin = result.data[i * w + 4];
6464
ssdData.xmax = result.data[i * w + 5];
6565
ssdData.ymax = result.data[i * w + 6];
66-
66+
6767
[array addObject:ssdData];
6868
}
69-
69+
7070
return array;
7171
}
7272

Demo/iOS/AICamera/AICamera/SSDData.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
@interface SSDData : NSObject
1212

13-
@property (nonatomic) NSString *label;
14-
@property (nonatomic) float accuracy;
15-
@property (nonatomic) float xmin;
16-
@property (nonatomic) float ymin;
17-
@property (nonatomic) float xmax;
18-
@property (nonatomic) float ymax;
13+
@property(nonatomic) NSString *label;
14+
@property(nonatomic) float accuracy;
15+
@property(nonatomic) float xmin;
16+
@property(nonatomic) float ymin;
17+
@property(nonatomic) float xmax;
18+
@property(nonatomic) float ymax;
1919

20-
@end
20+
@end

Demo/iOS/AICamera/AICamera/SSDDrawLayer.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,51 @@ import UIKit
1010

1111
class SSDDrawLayer: CAShapeLayer {
1212
var labelLayer = CATextLayer()
13-
13+
1414
required override init() {
1515
super.init()
1616
}
17-
17+
1818
required init?(coder aDecoder: NSCoder) {
1919
fatalError("init(coder:) has not been implemented")
2020
}
21-
21+
2222
func render(_ data: SSDData, model:SSDModel, isBackCamera:Bool) {
23-
23+
2424
let screenWidth = UIScreen.main.bounds.size.width
2525
let screenHeight = UIScreen.main.bounds.size.height
26-
26+
2727
let x = CGFloat(isBackCamera ? data.xmin : 1 - data.xmax) * screenWidth
2828
let y = CGFloat(data.ymin) * screenHeight
2929
let width = CGFloat(data.xmax - data.xmin) * screenWidth
3030
let height = CGFloat(data.ymax - data.ymin) * screenHeight
31-
31+
3232
if (model == SSDModel.FaceMobileNet160 && data.label != "aeroplane") {
3333
return;
3434
}
35-
35+
3636
//draw box
3737
self.path = UIBezierPath(roundedRect: CGRect(x: x, y: y, width: width, height: height), cornerRadius: 10).cgPath
3838
self.strokeColor = UIColor.cyan.cgColor
3939
self.lineWidth = 4.0
4040
self.fillColor = nil
4141
self.lineJoin = kCALineJoinBevel
42-
42+
4343
if (model == SSDModel.FaceMobileNet160) {
4444
//do not draw label for face
4545
return;
4646
}
47-
47+
4848
let text = String.init(format: "%@: %.02f", data.label, data.accuracy)
4949
var displayString = NSAttributedString(string: text, attributes: [
5050
NSStrokeColorAttributeName : UIColor.black,
5151
NSForegroundColorAttributeName : UIColor.white,
5252
NSStrokeWidthAttributeName : NSNumber(value: -6.0),
5353
NSFontAttributeName : UIFont.systemFont(ofSize: 20, weight: 3)
5454
])
55-
55+
5656
//draw label
57-
57+
5858
labelLayer.string = displayString
5959
labelLayer.frame = CGRect.init(x: x + 4, y: y + height - 22, width: 1000, height: 30)
6060
addSublayer(labelLayer)

Demo/iOS/AICamera/AICamera/SSDModel.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum SSDModel : String {
1212
case PascalMobileNet300 = "pascal_mobilenet_300_66.paddle"
1313
case FaceMobileNet160 = "face_mobilenet_160_91.paddle"
1414
case PascalVGG300 = "vgg_ssd_net.paddle"
15-
15+
1616
func normDimension() -> (Int32, Int32)
1717
{
1818
switch self
@@ -26,4 +26,3 @@ enum SSDModel : String {
2626
}
2727
}
2828
}
29-

Demo/iOS/AICamera/AICamera/SSDMultiboxLayer.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
import UIKit
1010

1111
class SSDMultiboxLayer: CALayer {
12-
12+
1313
func displayBoxs(with ssdDataList: NSMutableArray, model: SSDModel, isBackCamera: Bool){
1414
self.sublayers?.forEach({ (layer) in
1515
layer.removeFromSuperlayer()
1616
})
17-
17+
1818
for ssdData in ssdDataList {
1919
let boxLayer = SSDDrawLayer.init()
2020
boxLayer.render(ssdData as! SSDData, model: model, isBackCamera: isBackCamera)
21-
21+
2222
self.addSublayer(boxLayer)
2323
}
2424
}

0 commit comments

Comments
 (0)