Barcode reading, rotating camera

  1. 2 weeks ago

    Olivier C

    Apr 12 Pre-Release Testers, Xojo Pro Europe (Belgium, Brussels)

    Hi,

    I need to read barcodes and trying to implement Jason King iOS_Kit barcode reading demo.
    The demo works but the camera preview is not as expected, rotation is 90° counterclockwise which makes it difficult to find the right spot ;-)

    I found something on the forum (forum post ) but don’t know where to place the code and the structure.
    Also, the code doesn’t compile, I made some changes (maybe there’s the problem).

    Does someone know how to handle this device rotation ?

    Thanks !

    Structure CGAffineTransform
    X0 as single
    Xx as single 
    Xy as single
    Y0 as single
    Yx as single
    Yy as single 
    End structure
    
    Const pi = 3.14159
    Declare Function CGAffineTransformMakeRotation Lib CoreGraphicsLib (angle As CGFloat) As CGAffineTransform
    Declare Sub setTransform Lib UIKitLib selector "setTransform:" (obj_id As ptr, transform As CGAffineTransform)
    SetTransform(MyView.Handle, CGAffineTransformMakeRotation(pi/2))

    Make sure you are passing a handle to the GenericView or canvas within the iOSView, not the iOS view itself. I think that could be the problem here

  2. Jason K

    Apr 12 Pre-Release Testers

    Can you give more detail? I haven’t seen the camera being rotated. Is your device in landscape instead of portrait? Also what didn’t compile? As far as I know the current version of iOSKit should run just fine.

    If you have the code above in a method you’ll need to make the structure by right click add structure, it can’t be actually in the method.

  3. Olivier C

    Apr 12 Pre-Release Testers, Xojo Pro Europe (Belgium, Brussels)

    Hi Jason,

    I’m on the road so not in front of my Mac.
    I have build the iOSkit demo and installed on an iPad Air iOS 12.2.
    The app is always landscape, but whatever orientation I give, the preview is always 90deg to the left.

    What didn’t compile was:

    • The libs surrounded by double quote
    • the « angle as float »

    It’s not within iOSkit, it’s within the code as provided in the previous forum post.

  4. Jason K

    Apr 12 Pre-Release Testers

    I haven’t tested the iOSKit demo on an iPad since I don’t have one. You might have found something though. The code you posted should work ok. If the libs aren’t compiling correctly, change them from XYZLib to “XYZ.framework”. If you are having a compiler error on “angle as CGFloat” what Xojo version are you using? That’s a primitive type that has been in the language for several years.

  5. Olivier C

    Apr 12 Pre-Release Testers, Xojo Pro Europe (Belgium, Brussels)

    No compile errors with the code I provided, as I could build, they were occurring with the code from the previous post (see my link above).
    But with this code the app crashes, I placed it in the open event

  6. Jason K

    Apr 12 Pre-Release Testers

    I might be miss understanding but the post you linked to has all possible values you can pass into the metadata object types. Specify one or more of those when for what barcode types you want to decide. As for the crash please get a log from Console for what is happening. I’m wondering if you’re calling the function too early. Try delaying calling it until after the open event with a Timer.CallLater call

  7. Olivier C

    Apr 12 Pre-Release Testers, Xojo Pro Europe (Belgium, Brussels)

    @Jason K I might be miss understanding but the post you linked to has all possible values you can pass into the metadata object types.

    Doesn’t really matter, but scroll down the end of the post, there’s the rotation stuff.

    @Jason K Try delaying calling it until after the open event with a Timer.CallLater call

    I placed this code in a timer called 500ms after open event of BarcodeScannerView.
    I never reaches the step #4

    Const pi = 3.14159
    System.DebugLog("#1")
    Declare Function CGAffineTransformMakeRotation Lib CoreGraphicsLib (angle As CGFloat) As CGAffineTransform
    System.DebugLog("#2")
    Declare Sub setTransform Lib UIKitLib selector "setTransform:" (obj_id As ptr, transform As CGAffineTransform)
    System.DebugLog("#3")
    SetTransform(Self.Handle, CGAffineTransformMakeRotation(pi/2))
    System.DebugLog("#4")

    I also tried this code in a method called just before calling captureSession.StartRunning in StartReading

    @Jason K As for the crash please get a log from Console for what is happening

    Here’s the crash log, starting after pressing AVFoundations Demo, crashing as soon as I press Bacode Scanner

    Seems to be unrecognized selector on setTransform

    Apr 13 08:10:16 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: L2 Metrics on ifname en0: rssi: -46 (txFrames/txReTx/txFail) 4/0/0 -> (was/is) 0/0
    Apr 13 08:10:21 iPad-DiveFactory aggregated(CoreLocation)[62] <Notice>: {"msg":"CLCopyAppsUsingLocation", "event":"activity"}
    Apr 13 08:10:21 iPad-DiveFactory backboardd[52] <Notice>: touch up event count:2 starting 15.8789s ago lastPID:452 lastContextID:372D02D2
    Apr 13 08:10:21 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: L2 Metrics on ifname en0: rssi: -47 (txFrames/txReTx/txFail) 0/0/0 -> (was/is) 0/0
    Apr 13 08:10:22 iPad-DiveFactory backboardd(MultitouchHID)[52] <Notice>: [HID] [MT] dispatchEvent Dispatching event with 1 children, _eventMask=0x23 _childEventMask=0x3 Cancel=0 Touching=1 inRange=1
    Apr 13 08:10:22 iPad-DiveFactory SpringBoard(FrontBoard)[48] <Notice>: immediate edge swipe: failed
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [SpringBoard:48] Attempting to acquire assertion for iOS_Kit:452: <BKProcessAssertion: 0x15dd37530; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:\M-b\M^@\M-&F7E0831B906D>
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [iOS_Kit:452] Add assertion: <BKProcessAssertion: 0x15dd37530; id: 48-38DC0730-A295-419D-BE99-F7E0831B906D; name: com.apple.UIKit.KeyboardManagement.message; state: active; reason: finishTask; duration: 180.0s> {
        owner = <BSProcessHandle: 0x15de15650; SpringBoard:48; valid: YES>;
        flags = preventSuspend, preventThrottleDownUI, preventThrottleDownCPU, preventSuspendOnSleep;
    }
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [iOS_Kit:452] Activate assertion: <BKProcessAssertion: 0x15dd37530; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:\M-b\M^@\M-&F7E0831B906D>
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [iOS_Kit:452] Setting jetsam priority to 10 [0x10108]
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: Client relinquished <BKProcessAssertion: 0x15dd37530; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:\M-b\M^@\M-&F7E0831B906D>
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [iOS_Kit:452] Deactivate assertion: <BKProcessAssertion: 0x15dd37530; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:\M-b\M^@\M-&F7E0831B906D>
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [iOS_Kit:452] Setting jetsam priority to 10 [0x10100]
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [iOS_Kit:452] Remove assertion: <BKProcessAssertion: 0x15dd37530; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:\M-b\M^@\M-&F7E0831B906D>
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: -[BKAssertion dealloc] - <0x15dd37530>
    Apr 13 08:10:22 iPad-DiveFactory backboardd(MultitouchHID)[52] <Notice>: [HID] [MT] dispatchEvent Dispatching event with 1 children, _eventMask=0x2 _childEventMask=0x2 Cancel=0 Touching=0 inRange=1
    Apr 13 08:10:22 iPad-DiveFactory dasd(DuetActivitySchedulerDaemon)[87] <Notice>: com.apple.locationd.IndoorTilePrefetch:622E9B:[
    	{name: FileProtectionPolicy, policyWeight: 0.010, response: {Decision: Absolutely Must Not Proceed, Score: 0.00, Rationale: [{classALocked == 0 AND activityFileProtection == <File Protection: Class B>}]}}
     ], FinalDecision: Absolutely Must Not Proceed}
    Apr 13 08:10:22 iPad-DiveFactory iOS_Kit[452] <Notice>: #1
    Apr 13 08:10:22 iPad-DiveFactory iOS_Kit[452] <Notice>: #2
    Apr 13 08:10:22 iPad-DiveFactory iOS_Kit[452] <Notice>: #3
    Apr 13 08:10:22 iPad-DiveFactory iOS_Kit(CoreFoundation)[452] <Notice>: -[XOJViewController setTransform:]: unrecognized selector sent to instance 0x101534450
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [iOS_Kit:452] Setting jetsam priority to 3 [0x100]
    Apr 13 08:10:22 iPad-DiveFactory assertiond[58] <Notice>: [iOS_Kit:452] setpriority(PRIO_DARWIN_ROLE, 452, 3): ok
    Apr 13 08:10:22 iPad-DiveFactory mobilewatchdog[60] <Notice>: 77579975535500: id=@ pid=6475984, state=452
    Apr 13 08:10:22 iPad-DiveFactory backboardd(IOKit)[52] <Notice>: Connection removed: IOHIDEventSystemConnection uuid:ABF69FC9-22AB-40F8-B1AA-6CEA0F03AB4C pid:452 process:iOS_Kit type:Passive entitlements:0x0 caller:BackBoardServices: <redacted> + 364 attributes:<CFBasicHash 0x111021480 [0x10ff00010]>{type = immutable dict, count = 3,
    entries =>
    	0 : <CFString 0x10fd7cb30 [0x1e3689450]>{contents = "pid"} = <CFNumber 0x895b7cd46b34f5b7 [0x1e3689450]>{value = +452, type = kCFNumberSInt64Type}
    	1 : <CFString 0x10fd7a1f0 [0x1e3689450]>{contents = "bundleID"} = <CFString 0x111678960 [0x1e3689450]>{contents = "com.gate61.ioskit"}
    	2 : <CFString 0x111678900 [0x1e3689450]>{contents = "HighFrequency"} = <CFBoolean 0x1e368f018 [0x1e3689450]>{value = false}
    }
     inactive:0
    Apr 13 08:10:22 iPad-DiveFactory backboardd(IOKit)[52] <Notice>: Connection removed: IOHIDEventSystemConnection uuid:4B6FBA3F-F21E-4691-8256-A6E2E77201EA pid:452 process:iOS_Kit type:Monitor entitlements:0x0 caller:GameController: _GCHIDEventCallback + 92 attributes:(null) inactive:0
    Apr 13 08:10:22 iPad-DiveFactory SpringBoard(KeyboardArbiter)[48] <Error>: HW kbd: Failed to set (null) as keyboard focus
    Apr 13 08:10:22 iPad-DiveFactory backboardd[52] <Notice>: [BKEventFocusManager] Setting foreground application to: (none) (-1)
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Error>: Can't get most elevated app state from dictionary {
        BKSApplicationStateExtensionKey = 0;
        SBApplicationStateDisplayIDKey = "com.gate61.ioskit";
        SBApplicationStateKey = 0;
        SBApplicationStateProcessIDKey = 452;
        SBApplicationStateRunningReasonsKey =     (
                    {
                SBApplicationStateRunningReasonAssertionIdentifierKey = Resume;
                SBApplicationStateRunningReasonAssertionReasonKey = 10000;
            }
        );
    }
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: 452 com.gate61.ioskit: Unknown (most elevated: Unknown)
    Apr 13 08:10:22 iPad-DiveFactory SpringBoard(WiFiPicker)[48] <Notice>: WIFI PICKER [com.gate61.ioskit]: isProcessLaunch: 0,    isForegroundActivation: 0,     isForegroundDeactivation: 1
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: Entry, display name com.gate61.ioskit uuid (null) pid 452 isFront 0
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: Continue with bundle name com.gate61.ioskit, is front 0
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: com.gate61.ioskit: Foreground: false
    Apr 13 08:10:22 iPad-DiveFactory ReportCrash(CrashReporterSupport)[453] <Notice>: Trying to create CR directory structure as root
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: Failed to find process for com.gate61.ioskit
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: NBSM Current state: normal, changed: systemForeground to 0 for net type 0
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: NBSM Eligible to go to broken
    Apr 13 08:10:22 iPad-DiveFactory symptomsd(SymptomEvaluator)[120] <Notice>: NBSM Current state: normal, changed: systemForeground to 0 for net type 0, eligible for broken but constraints unsatisfied (0,0)
    Apr 13 08:10:22 iPad-DiveFactory ReportCrash(CrashReporterSupport)[453] <Notice>: cr_update: <private>
    Apr 13 08:10:23 iPad-DiveFactory ReportCrash[453] <Notice>: Formulating report for corpse[452] iOS_Kit
    Apr 13 08:10:23 iPad-DiveFactory ReportCrash(CoreServices)[453] <Notice>: notify_register_check() failed with error 1000000
  8. Olivier C

    Apr 12 Pre-Release Testers, Xojo Pro Europe (Belgium, Brussels)

    If the rotation issue is not clear, here’s a mockup:
    -image-

  9. Jason K

    Apr 13 Pre-Release Testers Answer

    Make sure you are passing a handle to the GenericView or canvas within the iOSView, not the iOS view itself. I think that could be the problem here

  10. Olivier C

    Apr 14 Pre-Release Testers, Xojo Pro Europe (Belgium, Brussels)

    Thanks Jason !
    Now it’s fine, using the handle of the GenericView, and placing the code just before captureSession.StartRunning.

  11. Jason K

    Apr 14 Pre-Release Testers

    Excellent glad that solved it!

or Sign Up to reply!