Repository navigation
Expand file tree
/
Copy pathCameraExampleViewController.mm
More file actions
executable file
·683 lines (535 loc) · 25.8 KB
/
Copy pathCameraExampleViewController.mm
File metadata and controls
executable file
·683 lines (535 loc) · 25.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import <AssertMacros.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <CoreImage/CoreImage.h>
#import <ImageIO/ImageIO.h>
#import "CameraExampleViewController.h"
#import <mach/mach.h>
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
#include "google/protobuf/message_lite.h"
#include <sys/time.h>
#include "ios_image_load.h"
#import <Photos/Photos.h>
#include <fstream>
#include <pthread.h>
#include <unistd.h>
#include <queue>
#include <sstream>
#include <string>
#include "tensorflow_utils.h"
#import "Model.h"
#import "ModelManager.h"
#import "MWPhoto+BadPhoto.h"
// If you have your own model, modify this to the file name, and make sure
// you've added the file to your app resources too.
static NSString* model_file_name = @"mmapped_kids_graph";
static NSString* model_file_type = @"pb";
// This controls whether we'll be loading a plain GraphDef proto, or a
// file created by the convert_graphdef_memmapped_format utility that wraps a
// GraphDef and parameter file that can be mapped into memory from file to
// reduce overall memory usage.
const bool model_uses_memory_mapping = true;
// If you have your own model, point this to the labels file.
static NSString* labels_file_name = @"retrained_kids_label";
static NSString* labels_file_type = @"txt";
// These dimensions need to match those the model was trained with.
const int wanted_input_width = 299;
const int wanted_input_height = 299;
const int wanted_input_channels = 3;
const float input_mean = 128.0f;
const float input_std = 128.0f;
const std::string input_layer_name = "Mul";
const std::string output_layer_name = "final_result";
@implementation CameraExampleViewController
@synthesize photos,thumbs, assets;
NSString* FilePathForResourceNameDup(NSString* name, NSString* extension) {
NSString* file_path = [[NSBundle mainBundle] pathForResource:name ofType:extension];
if (file_path == NULL) {
LOG(FATAL) << "Couldn't find '" << [name UTF8String] << "."
<< [extension UTF8String] << "' in bundle.";
}
return file_path;
}
- (IBAction)getUrl:(id)sender {
// if(self.photos.count > 0){
// [self showResult:sender];
//} else {
currentJ = 0;
self.lblFound.text = [NSString stringWithFormat:@"Found : %d ",0];
self.progressView.value = 0;
[self.photos removeAllObjects];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@autoreleasepool {
[self loadAssets];
}
dispatch_async(dispatch_get_main_queue(), ^()
{
// call completion block on main
[self scanCompleted];
});
});
[scan setEnabled:NO];
//}
}
-(void) scanCompleted
{
//Enable Scan button for next Scan
[scan setEnabled:YES];
}
- (IBAction)viewResults:(id)sender
{
if(self.photos.count > 0)
{
[self showResult:sender];
}
}
- (void)loadAssets {
unsigned int mem = [self memoryInMB];
//if( mem > 512)
{ NSLog(@"Memory11 : %u", mem);
// sleep(5);
// continue;
}
if (NSClassFromString(@"PHAsset")) {
// Check library permissions
PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
if (status == PHAuthorizationStatusNotDetermined) {
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if (status == PHAuthorizationStatusAuthorized) {
[self findAllFiles];
}
}];
} else if (status == PHAuthorizationStatusAuthorized) {
[self findAllFiles];
}
} else {
// Assets library
[self findAllFiles];
}
mem = [self memoryInMB];
//if( mem > 512)
{ NSLog(@"Memory12 : %u", mem);
// sleep(5);
// continue;
}
}
int currentJ=0;
-(void) findAllFiles
{
NSDate *methodStart = [NSDate date];
//-------- xb -------------
ModelManager *mgrObj=[ModelManager getInstance];
//-------- xb -------------
NSMutableDictionary *tst =[[NSMutableDictionary alloc]init];
tst = [mgrObj retrieveAllData];
PHImageRequestOptions *requestOptions = [[PHImageRequestOptions alloc] init];
requestOptions.resizeMode = PHImageRequestOptionsResizeModeExact;
requestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeFastFormat;
requestOptions.synchronous = true;
requestOptions.networkAccessAllowed = NO;
PHFetchOptions *options = [PHFetchOptions new];
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]];
//set up fetch options, mediaType is image.
options.predicate = [NSPredicate predicateWithFormat:@"mediaType = %d",PHAssetMediaTypeImage];
//PHFetchResult *result = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:options];
PHFetchResult *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
PHImageManager *manager = [PHImageManager defaultManager];
// assets contains PHAsset objects.
UIScreen *screen = [UIScreen mainScreen];
CGFloat scale = screen.scale;
// Sizing is very rough... more thought required in a real implementation
CGFloat imageSize = MAX(screen.bounds.size.width, screen.bounds.size.height) * 1.5;
CGSize imageTargetSize = CGSizeMake(imageSize * scale, imageSize * scale);
CGSize thumbTargetSize = CGSizeMake(imageSize / 3.0 * scale, imageSize / 3.0 * scale);
int maxResult = 500;
for (NSInteger i =0; i < result.count; i++) {
PHAssetCollection *assetCollection = result[i];
PHFetchResult *assetsFetchResult = [PHAsset fetchAssetsInAssetCollection:assetCollection options:options];
//Only Work For Selfies
if([assetCollection.localizedTitle containsString:@"Selfies"] == false)
{
continue;
}
NSLog(@"Sub album title is %@, count is %ld", assetCollection.localizedTitle, assetsFetchResult.count);
if (assetsFetchResult.count > 0) {
//-------- xb -------------
Model *picData = [[Model alloc]init];
//-------- xb -------------
for (int j =currentJ; (j < (int)assetsFetchResult.count && self.photos.count < maxResult);) {
// This autorelease pool seems good (a1)
@autoreleasepool {
unsigned int mem = [self memoryInMB];
//if( mem > 512)
{ NSLog(@"Memory : %u", mem);
// sleep(5);
// continue;
}
// Do something with the asset
__block BOOL isICloudAsset = NO;
PHAsset *asset =assetsFetchResult[j++];
NSLog(@"the Local Identifier name is : %@", asset.localIdentifier);
[manager requestImageForAsset:asset
targetSize:PHImageManagerMaximumSize
contentMode:PHImageContentModeDefault
options:requestOptions
resultHandler:^void(UIImage *image, NSDictionary *dict) {
if ([dict[@"PHImageResultIsInCloudKey"] isEqual:@YES]) {
isICloudAsset = YES;
}
if(!isICloudAsset){
@autoreleasepool {
NSMutableDictionary *newValues = [NSMutableDictionary dictionary];
//-------- xb -------------
//picData.URL = [dict objectForKey:@"PHImageFileURLKey"];
picData.URL = asset.localIdentifier;
//-------- xb -------------
//NSString *url = [NSString stringWithFormat:@"%@", [dict objectForKey:@"PHImageFileURLKey"]];
NSString *url = [NSString stringWithFormat:@"%@", asset.localIdentifier];
Model *obj = [mgrObj getRecord:tst withName:url];
bool badPhoto = false;
if (!obj)
{
badPhoto = [self RunInferenceOnImage:image :[dict objectForKey:@"PHImageFileURLKey"] :newValues];
}
else
{
badPhoto = [obj.bad_image boolValue];
}
//-------- xb -------------
if(badPhoto)
{
picData.bad_image = @"1";
}
else
{
picData.bad_image = @"0";
}
picData.state = @"0";
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"dd.MM.YY HH:mm:ss"];
picData.scan_date = [dateFormatter stringFromDate:currDate];
if (!obj)
{
[mgrObj insertData:picData];
}
//-------- xb -------------
//image = nil;
if(badPhoto){
NSLog(@"Scanning Selfies: %d / %d - %lu",j,(int)assetsFetchResult.count, (unsigned long)self.photos.count);
MWPhoto *photo = [MWPhoto photoWithAsset:asset targetSize:thumbTargetSize];
photo.photoUrl = [NSURL URLWithString:asset.localIdentifier];//[dict objectForKey:@"PHImageFileURLKey"];
[self.photos addObject:photo];
[_selections addObject:[NSNumber numberWithBool:0]];
[self.thumbs addObject:[MWPhoto photoWithAsset:asset targetSize:thumbTargetSize]];
}else
image = nil;
}
}
}];
dispatch_async(dispatch_get_main_queue(), ^(void) {
[UIView animateWithDuration: 1.f animations:^{
self.progressView.value = (float)(j/(float)assetsFetchResult.count) * 100;
}];
self.lblFound.text = [NSString stringWithFormat:@"Found : %lu ",(unsigned long)self.photos.count];
});
if(self.photos.count > maxResult){
currentJ = j;
break;
}
}
}
}
}
requestOptions = nil;
options = nil;
result = nil;
NSDate *methodFinish = [NSDate date];
NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:methodStart];
NSLog(@"executionTime = %f", executionTime);
}//End of findAllFiles
-(unsigned) memoryInMB{
unsigned latest = 0;
struct task_basic_info info;
mach_msg_type_number_t size = sizeof(info);
kern_return_t kerr = task_info(mach_task_self(),
TASK_BASIC_INFO,
(task_info_t)&info,
&size);
if( kerr == KERN_SUCCESS ) {
latest = (int)info.resident_size/1024/1024;
} else {
NSLog(@"Error with task_info(): %s", mach_error_string(kerr));
}
return latest;
}
- (bool)RunInferenceOnImage: (UIImage *) image :(NSString*) info : (NSMutableDictionary *) newValues {
bool isBadPhoto = false;
int image_channels = 4;
tensorflow::Tensor image_tensor(
tensorflow::DT_FLOAT,
tensorflow::TensorShape(
{1, wanted_input_height, wanted_input_width, wanted_input_channels}));
auto image_tensor_mapped = image_tensor.tensor<float, 4>();
float* out = image_tensor_mapped.data();
int image_height;
int image_width;
//std::vector<tensorflow::uint8> image_data = LoadImageFromFile(
// [image_path UTF8String], &image_width,
//&image_height, &image_channels);
unsigned char * image_data = [ImageHelper convertUIImageToBitmapRGBA8:image :&image_width :&image_height :&image_channels];
/*
CGImageRef imageRef = [image CGImage];
CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(imageRef));
const unsigned char * buffer = CFDataGetBytePtr(data);
*/
assert(image_channels >= wanted_input_channels);
tensorflow::uint8* in = image_data;
for (int y = 0; y < wanted_input_height; ++y) {
const int in_y = (y * image_height) / wanted_input_height;
tensorflow::uint8* in_row = in + (in_y * image_width * image_channels);
float* out_row = out + (y * wanted_input_width * wanted_input_channels);
for (int x = 0; x < wanted_input_width; ++x) {
const int in_x = (x * image_width) / wanted_input_width;
tensorflow::uint8* in_pixel = in_row + (in_x * image_channels);
float* out_pixel = out_row + (x * wanted_input_channels);
for (int c = 0; c < wanted_input_channels; ++c) {
out_pixel[c] = (in_pixel[c] - input_mean) / input_std;
}
}
}
if (tf_session.get()) {
std::vector<tensorflow::Tensor> outputs;
tensorflow::Status run_status = tf_session->Run(
{{input_layer_name, image_tensor}}, {output_layer_name}, {}, &outputs);
if (!run_status.ok()) {
LOG(ERROR) << "Running model failed:" << run_status;
} else {
tensorflow::Tensor *output = &outputs[0];
auto predictions = output->flat<float>();
for (int index = 0; index < predictions.size(); index += 1) {
const float predictionValue = predictions(index);
if (predictionValue > 0.5f) {
std::string label = labels[index % predictions.size()];
NSString *labelObject = [NSString stringWithCString:label.c_str()];
NSNumber *valueObject = [NSNumber numberWithFloat:predictionValue];
[newValues setObject:valueObject forKey:labelObject];
NSLog(@"Prediction Value: %f ", predictionValue );
isBadPhoto = predictionValue > 0.8f && ([labelObject containsString:@"black"] || [labelObject containsString:@"phonescreen"]) ;
isBadPhoto = isBadPhoto ? isBadPhoto : predictionValue > 0.8f && ([labelObject containsString:@"bad photos"]) ;
}
}
if(isBadPhoto){
NSString *log = [NSString stringWithFormat:@"%@\n", newValues];
NSLog(@"Bad Photo %@", log);
//display new value;
/*dispatch_async(dispatch_get_main_queue(), ^(void) {
self.urlContentTextView.text = [NSString stringWithFormat:@"%@\n/%@-%@", self.urlContentTextView.text, info,newValues];
});*/
}
}
}
free(image_data);
return isBadPhoto;
}
- (BOOL)textFieldShouldReturn:(UITextField *)aTextField
{
[aTextField resignFirstResponder];
return YES;
}
- (void)dealloc {
/*
[_badPhotos release];
[_showResultBtn release];
[_maxResults release];
[_progressView release];
[_lblFound release];
[_progressView release];
[super dealloc];
*/
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Initialise
self.assets = [NSMutableArray new];
self.photos = [[NSMutableArray alloc] init];
_selections = [[NSMutableArray alloc] init];
self.thumbs = [[NSMutableArray alloc] init];
tensorflow::Status load_status;
if (model_uses_memory_mapping) {
load_status = LoadMemoryMappedModel(
model_file_name, model_file_type, &tf_session, &tf_memmapped_env);
} else {
load_status = LoadModel(model_file_name, model_file_type, &tf_session);
}
if (!load_status.ok()) {
LOG(FATAL) << "Couldn't load model: " << load_status;
}
// self.maxResults.delegate = self;
tensorflow::Status labels_status =
LoadLabels(labels_file_name, labels_file_type, &labels);
if (!labels_status.ok()) {
LOG(FATAL) << "Couldn't load labels: " << labels_status;
}
}
- (void)viewDidUnload {
[super viewDidUnload];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
#pragma mark - MWPhotoBrowserDelegate
- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
return self.photos.count;
}
- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
if (index < self.photos.count)
return [self.photos objectAtIndex:index];
return nil;
}
- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index {
if (index < self.thumbs.count)
return [self.thumbs objectAtIndex:index];
return nil;
}
- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index {
NSLog(@"Did start viewing photo at index %lu", (unsigned long)index);
}
- (BOOL)photoBrowser:(MWPhotoBrowser *)photoBrowser isPhotoSelectedAtIndex:(NSUInteger)index {
return [[_selections objectAtIndex:index] boolValue];
}
- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index selectedChanged:(BOOL)selected {
[_selections replaceObjectAtIndex:index withObject:[NSNumber numberWithBool:selected]];
NSString *key = [NSString stringWithFormat:@"%li", (unsigned long)index];
if ([_selectedImages objectForKey:key]) {
[_selectedImages setObject:key forKey: key];
}
// NSLog(@"selection count -------- %@",_selections.count);
NSLog(@"%lu",(unsigned long)_selections.count);
NSLog(@"Photo at index %lu selected %@", (unsigned long)index, selected ? @"YES" : @"NO");
}
- (void)photoBrowserDidFinishModalPresentation:(MWPhotoBrowser *)photoBrowser {
// If we subscribe to this method we must dismiss the view controller ourselves
NSLog(@"Did finish modal presentation");
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)photoBrowserDidRemoveFinishModalPresentation:(MWPhotoBrowser *)photoBrowser {
// If we subscribe to this method we must dismiss the view controller ourselves
NSLog(@"Did remove finish modal presentation");
NSLog(@"in loop");
NSMutableArray *photoesToDelete = [[NSMutableArray alloc] init];
for (int i = self.photos.count - 1; i >= 0; i--)
{
NSLog(@"index %d value %@",i,_selections[i]);
if ([_selections objectAtIndex:i] == [NSNumber numberWithBool:1] )
{
NSLog(@"Deleting %d coz value %@",i,_selections[i]);
[_selections replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:false]];
NSString *key = [NSString stringWithFormat:@"%li", (unsigned long)i];
if ([_selectedImages objectForKey:key])
{
[_selectedImages setObject:key forKey: key];
}
//Delete Image from Photo Liberary
MWPhoto *asset = [photos objectAtIndex:i];
[photoesToDelete addObject:asset.photoUrl.absoluteString];
NSLog(@"%@", asset.photoUrl);
//Remove from Browser collection as well
[photos removeObjectAtIndex:i];
[thumbs removeObjectAtIndex:i];
}//End IF Block for Item selection for deletion
}//End For Loop
//Remove photoes from the library
[self deleteAssetWithLocalIdentifiers:photoesToDelete];
[self dismissViewControllerAnimated:YES completion:nil];
} //End of photoBrowserDidRemoveFinishModalPresentation
-(void)deleteAssetWithLocalIdentifiers:(NSMutableArray*)assetObjects
{
if (assetObjects == nil)
{
return;
}
if(assetObjects.count == 0)
{
return;
}
NSLog(@" deleting objects: %d", assetObjects.count);
PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:assetObjects options:nil];
if (result.count > 0)
{
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, result.count)];
//Get Assets from the specified indexes
NSArray *assetToBeDeleted = [result objectsAtIndexes:indexSet];
// PHAsset *phAsset = result.firstObject;
// if ((phAsset != nil) && ([phAsset canPerformEditOperation:PHAssetEditOperationDelete]))
{
NSLog(@" Last delete objects req: %d", assetToBeDeleted.count);
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^
{
[PHAssetChangeRequest deleteAssets:assetToBeDeleted];
}
completionHandler:^(BOOL success, NSError *error)
{
if ((!success) && (error != nil))
{
NSLog(@"Error deleting asset: %@", [error description]);
}
}];
}
}//End of if (result.count > 0)
}//ENd of deleteAssetWithLocalIdentifiers
- (IBAction)showResult:(id)sender {
//Initilize selected images dic
_selectedImages =[[NSMutableDictionary alloc] init];
MWPhotoBrowser *browser
= [[MWPhotoBrowser alloc] initWithDelegate:self];
// Set options
browser.displayActionButton = YES; // Show action button to allow sharing, copying, etc (defaults to YES)
browser.displayNavArrows = NO; // Whether to display left and right nav arrows on toolbar (defaults to NO)
//ZEE browser.displaySelectionButtons = NO; // Whether selection buttons are shown on each image (defaults to NO)
browser.displaySelectionButtons = YES;
browser.zoomPhotosToFill = YES; // Images that almost fill the screen will be initially zoomed to fill (defaults to YES)
browser.alwaysShowControls = NO; // Allows to control whether the bars and controls are always visible or whether they fade away to show the photo full (defaults to NO)
browser.enableGrid = YES; // Whether to allow the viewing of all the photo thumbnails on a grid (defaults to YES)
browser.startOnGrid = YES; // Whether to start on the grid of thumbnails instead of the first photo (defaults to NO)
browser.autoPlayOnAppear = NO; // Auto-play first video
[browser setCurrentPhotoIndex:0];
// Present
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:browser];
nc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:nc animated:YES completion:nil];
}
@end