twelve17 / openalpr-ios

Xcode Framework for the openalpr library
GNU General Public License v3.0
116 stars 35 forks source link

Terminated due to memory issue on physical device #22

Open bradleygolden opened 8 years ago

bradleygolden commented 8 years ago

I've ran openalpr-ios on the simulator with success. Now I'm trying to run the project on an iPhone 6s (9.3.1) and each time I get the following output in my debug console:

Missing config value for runtime_dir
Missing config value for detector
Missing config value for detection_iteration_increase
Missing config value for detection_strictness
Missing config value for max_plate_width_percent
Missing config value for max_plate_height_percent
Missing config value for max_detection_input_width
Missing config value for max_detection_input_height
Missing config value for contrast_detection_threshold
Missing config value for must_match_pattern
Missing config value for skip_detection
Missing config value for detection_mask_image
Missing config value for analysis_count
Missing config value for prewarp
Missing config value for max_plate_angle_degrees
Missing config value for ocr_img_size_percent
Missing config value for state_id_img_size_percent
Missing config value for ocr_min_font_point
Missing config value for postprocess_min_confidence
Missing config value for postprocess_confidence_skip_level
Missing config value for debug_general
Missing config value for debug_timing
Missing config value for debug_prewarp
Missing config value for debug_detector
Missing config value for debug_state_id
Missing config value for debug_plate_lines
Missing config value for debug_plate_corners
Missing config value for debug_char_segment
Missing config value for debug_char_analysis
Missing config value for debug_color_filter
Missing config value for debug_ocr
Missing config value for debug_postprocess
Missing config value for debug_show_images
Missing config value for debug_pause_on_frame
Message from debugger: Terminated due to memory issue

I've enabled the "Address Sanitizer" under the "Diagnostics" tab to determine if I could find where the memory issue is occurring. After enabling, Address Sanitizer break points in PlateScanner.mm at this point in the code:

screen shot 2016-04-04 at 11 43 55 am

Address Sanitizer outputs this error in the console:

==1173==ERROR: AddressSanitizer failed to allocate 0x215a4000 (559562752) bytes of LargeMmapAllocator (error code: 12)
==1173==Process memory map follows:
    0x01955f4000-0x0195607000   /System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Libraries/libCGInterfaces.dylib
    0x01a19b4000-0x01a19b4034   /System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Libraries/libCGInterfaces.dylib
    0x01a00b0000-0x01a00b0bf8   /System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Libraries/libCGInterfaces.dylib

...

    #43 0x18865df6f in UIApplicationMain (/System/Library/Frameworks/UIKit.framework/UIKit+0x7df6f)
    #44 0x100055f33 in main (/var/containers/Bundle/Application/EB9E5DE6-CC0E-4126-A8CB-BCBA8D423DF5/AlprSample.app/AlprSample+0x100011f33)
    #45 0x182f268b7 in <redacted> (/usr/lib/system/libdyld.dylib+0x28b7)

I've noticed the app loads okay so long as I don't provide it an image, but this doesn't help me much. I'm not sure how to go about this issue.

kstott commented 8 years ago

I am having exact same issue. If anyone has a solution, I would like to know.

alvinbaena commented 8 years ago

I'm also having the same issue, except I'm on an iPhone 4s with iOS 9.2.1.

kstott commented 8 years ago

iOS 9.3, iPhone 6

alvinbaena commented 8 years ago

I managed to fix it by copying the contents of the openalpr.conf.defaults (from here) to the openalpr.conf that should be linked in the project.

When I say it works i mean it crashes after 4 detections (memory) and takes like 20 seconds instantiating the PlateScanner object, but it works.

Maybe the settings defined in the file should be tweaked for better performance, but I'm really new at this detection business.

kstott commented 8 years ago

I believe the issue was:

max_detection_input_width = 1280 max_detection_input_height = 720

It now works for me as well - at least with one iteration. Second iteration never works. No errors, but it never recognizes plates even when using the exact same image.

PhilippOtto89 commented 8 years ago

Same issue here. Any working solution?

renatosc commented 8 years ago

Same issue here. @alvinbaena solution above worked for me

ducnmisbk commented 8 years ago

as @alvinbaena 's solution, now i can build project to device but It can not recognize plate even when I used to do in simulator