IOS8 Objective-C SignaturePoint CGRectValue - objective-c

Below is the output for "signature.rawPoints" with 32bit architecture Objective-C code
(
"NSRect: {{130, 142.5}, {2.3333333, 100}}",
"NSRect: {{136, 139.5}, {2.4990008, 101}}",
"NSRect: {{152.25, 131}, {2.0691545, 102}}",
"NSRect: {{169.75, 121}, {1.7328094, 103}}",
"NSRect: {{185.25, 111}, {1.5653242, 104}}",
"NSRect: {{196.125, 104}, {1.6099705, 105}}",
"NSRect: {{200.75, 101.375}, {1.9532523, 106}}"
),
But with 64bit architecture along with IOS8 below is the output
(
"\nlocation: 87.000000,112.000000\nvelocity: 0.000000,0.000000\nacceleration: 0.000000,0.000000\ntimestamp: 19476.794956\npressure: 1.000000\ndiameter: 4.666667\nid: 100",
"\nlocation: 88.000000,116.000000\nvelocity: 22.341108,89.364433\nacceleration: 499.125115,1996.500461\ntimestamp: 19476.839717\npressure: 1.000000\ndiameter: 5.006714\nid: 101",
"\nlocation: 92.000000,125.000000\nvelocity: 228.450167,514.012876\nacceleration: 11771.412252,24252.751985\ntimestamp: 19476.857226\npressure: 1.000000\ndiameter: 4.700317\nid: 102",
"\nlocation: 97.000000,134.000000\nvelocity: 298.178096,536.720573\nacceleration: 4158.268213,1354.187550\ntimestamp: 19476.873995\npressure: 1.000000\ndiameter: 4.437694\nid: 103")
The below code is not working with 64-bit architecture on the above rawpoints to find CGRectValues.
CGRect r1 = [[[signature.rawPoints objectAtIndex:i]objectAtIndex:j] CGRectValue];
Error:
2015-06-04 19:18:45.933 MySampleCloset UAT[40174:865394]
-[T1SignaturePoint CGRectValue]: unrecognized selector sent to instance 0x7f90d86b75a0 2015-06-04 19:18:45.977 MySampleCloset
UAT[40174:865394] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[T1SignaturePoint
CGRectValue]: unrecognized selector sent to instance 0x7f90d86b75a0'
Please suggest a solution.

Check your code carefully. Unrecognized selector means, that you try to use method to "wrong" object, like treating NSString as an NSArray for example, and sending NSString objectAtIndex message.
Or maybe, you using some kind of 3rd libraries, and they are not updated for 64 bit architecture.
If you want better answer then that, edit your code with CMD+K and show us your code..

TSignaturePoint.h added into the latest third point TSignature library, so we have to use the below code to find the x and y co ordinates for the signature of every letter.
CGPoint p = [[[signature.rawPoints objectAtIndex:i]objectAtIndex:j] location];
Note: [[signature.rawPoints objectAtIndex:i]objectAtIndex:j] is the type of TSignature.
we can also write the above as below
TSignature * sig = [[signature.rawPoints objectAtIndex:i]objectAtIndex:j];
CGPoint p = sig.location;

Related

OpenCV BackgroundSubtractor.getBackgroundImage crashes with invalid frame type

I'm using OpenCV in an iOS app via Objective-C wrapper and it works generally fine but an attempt to read a background image from a background subtractor crashes the app:
cv::Ptr<BackgroundSubtractor> backSub = createBackgroundSubtractorMOG2();
for (int i = 0; i < arr.count; i++) { // arr - NSArray of UIImage
Mat mask;
Mat frame = [OpenCVWrapper _matFrom:arr[i]]; // converts UIImage to OpenCV.Mat
backSub->apply(frame, mask); // this works great, I can read the mask and it's valid
}
Mat background;
backSub->getBackgroundImage(background); // this crashes
The error implies that my frame has an invalid format. But in my case, I'm just creating a variable to be used by the getBackgroundImage. I tried to create a new Mat with the expected type CV_8UC1 (and CV_8UC3) with no luck, the app is still crashing with the same error.
libc++abi: terminating with uncaught exception of type cv::Exception: OpenCV(4.3.0) /Volumes/build-storage/build/master_iOS-mac/opencv/modules/video/src/bgfg_gaussmix2.cpp:929: error: (-215:Assertion failed) frameType == CV_8UC1 || frameType == CV_8UC3 || frameType == CV_32FC1 || frameType == CV_32FC3 in function 'getBackgroundImage'
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
Same code works flawlessly in my python test (declare variable and store the background there):
background = backSub.getBackgroundImage()
How should I properly access a background image from createBackgroundSubtractorMOG2 in Objective-C?

Xcode error: "passing 'float' to parameter of incompatible type id"

I have set a variable radius in my Objective C implentation file:
float radius = MIN(bounds.origin.x, bounds.origin.y) / 2.0;
I am trying to check the value of it, so I added in:
NSLog(radius);
Xcode gives me this error at the end of the line:
Passing 'float' to parameter of incompatible type id
Why is it expecting an 'id', and why can't it log a float?
This solved it:
NSLog(#"%f", radius);
It appears that NSLog only accepts a formatted string.

openCL "Arguments mismatch for instruction 'mov'" error

So one of my devices (a Nvidia GeForce GT 650m GPU) keeps giving me this weird ptxas application error saying "Arguments mismatch for instruction 'mov' when I try to build a cl_program on that device. It's the only one of my 3 devices that gives me this error. My CPU and other GPU (Intel HD 4000) do not give me this error at all.
Here's an example of a function that causes this error to happen. It's a helper function I use inside one of my kernels:
//Calculate the dot product of two vectors
float Dot(Vector v1, Vector v2)
{
return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
}
First I tried splitting up the work into something like this:
//Calculate the dot product of two vectors)
float Dot(Vector v1, Vector v2)
{
float a = v1.x*v2.x;
float b = v1.y*v2.y;
float c = v1.z*v2.z;
float result = a + b + c;
return result;
}
But that also gives me the same error. Interestingly enough, if I simply set result = 5.0f and return that it magically compiles and runs:
//THIS WILL COMPILE AND RUN
float Dot(Vector v1, Vector v2)
{
float a = v1.x*v2.x;
float b = v1.y*v2.y;
float c = v1.z*v2.z;
float result = 5.0f; //IGNORE THE CALCULATION. JUST MAKE IT 5
return result;
}
So I have no idea what's going on. My 'Dot' function isn't the only function that's affected but one of several. Is my Nvidia card defective?
EDIT Here is the log I get from clGetProgramBuildInfo after the build fails:
ptxas application ptx input, line 703; error : Arguments mismatch for instruction 'mov'
ptxas application ptx input, line 703; error : Unknown symbol 'LIntersection_2E_n'
ptxas application ptx input, line 703; error : Label expected for forward reference of 'LIntersection_2E_n'
ptxas fatal : Ptx assembly aborted due to errors
Although there are more errors printed than just the 'mov' one I described, they all go away when I make the above change of result = 5.0f;
According to the LLVM developers, this is a bug in the nvptx back-end.
LLVMdev forum message discussing this error

SuperCollider not audible on headphone

I am just beginning to learn audio programming using supercollider.
When I play a sound I am able to hear it on speakers but not headphone.
I get the following message on starting server -
booting 57110
localhost
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 48000.000000, driver's block size = 1024
JackDriver: connected system:capture_1 to SuperCollider:in_1
JackDriver: connected system:capture_2 to SuperCollider:in_2
JackDriver: connected SuperCollider:out_1 to system:playback_1
JackDriver: connected SuperCollider:out_2 to system:playback_2
SuperCollider 3 server ready.
JackDriver: max output latency 42.7 ms
Receiving notification messages from server localhost
Shared memory server interface initialized
I went through some forums and they suggested to look for output devices options and set them, I did a -
ServerOptions.devices;
to look for device list but I got the following error in the post window -
ERROR: A primitive was not bound. 0 676
Instance of Method { (0x21199c0, gc=01, fmt=00, flg=11, set=04)
instance variables [15]
raw1 : Float 0.000000 00000000 0080000C
raw2 : Float 0.000000 00000300 03020003
code : instance of Int8Array (0x2119cc0, size=4, set=2)
selectors : nil
constants : nil
prototypeFrame : instance of Array (0x2119c00, size=3, set=2)
context : nil
argNames : instance of SymbolArray (0x2119b40, size=3, set=2)
varNames : nil
sourceCode : nil
ownerClass : class Meta_ServerOptions (0x21113c0)
name : Symbol 'prListDevices'
primitiveName : Symbol '_ListAudioDevices'
filenameSymbol : Symbol '/usr/share/SuperCollider/SCClassLibrary/Common/Control/Server.sc'
charPos : Integer 4025
}
ERROR: Primitive 'none' failed.
Failed.
RECEIVER:
nil
CALL STACK:
MethodError:reportError 0x3601498
arg this =
Nil:handleError 0x1f730f8
arg this = nil
arg error =
Thread:handleError 0x35fcfd8
arg this =
arg error =
Object:throw 0x3980c58
arg this =
Object:primitiveFailed 0x33395a8
arg this = nil
Interpreter:interpretPrintCmdLine 0x3d061e8
arg this =
var res = nil
var func =
var code = "ServerOptions.devices;"
var doc = nil
var ideClass =
Process:interpretPrintCmdLine 0x3443c08
arg this =
^^ The preceding error dump is for ERROR: Primitive 'none' failed.
Failed.
RECEIVER: nil
booting 57110
localhost
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 48000.000000, driver's block size = 1024
JackDriver: connected system:capture_1 to SuperCollider:in_1
JackDriver: connected system:capture_2 to SuperCollider:in_2
JackDriver: connected SuperCollider:out_1 to system:playback_1
JackDriver: connected SuperCollider:out_2 to system:playback_2
SuperCollider 3 server ready.
JackDriver: max output latency 42.7 ms
Receiving notification messages from server localhost
Shared memory server interface initialized
ERROR: A primitive was not bound. 0 676
Instance of Method { (0x21199c0, gc=01, fmt=00, flg=11, set=04)
instance variables [15]
raw1 : Float 0.000000 00000000 0080000C
raw2 : Float 0.000000 00000300 03020003
code : instance of Int8Array (0x2119cc0, size=4, set=2)
selectors : nil
constants : nil
prototypeFrame : instance of Array (0x2119c00, size=3, set=2)
context : nil
argNames : instance of SymbolArray (0x2119b40, size=3, set=2)
varNames : nil
sourceCode : nil
ownerClass : class Meta_ServerOptions (0x21113c0)
name : Symbol 'prListDevices'
primitiveName : Symbol '_ListAudioDevices'
filenameSymbol : Symbol '/usr/share/SuperCollider/SCClassLibrary/Common/Control/Server.sc'
charPos : Integer 4025
}
ERROR: Primitive 'none' failed.
Failed.
RECEIVER:
nil
CALL STACK:
MethodError:reportError 0x35be518
arg this =
Nil:handleError 0x1ee0b78
arg this = nil
arg error =
Thread:handleError 0x3470ab8
arg this =
arg error =
Object:throw 0x3636a78
arg this =
Object:primitiveFailed 0x3cd86c8
arg this = nil
Interpreter:interpretPrintCmdLine 0x3d44b98
arg this =
var res = nil
var func =
var code = "ServerOptions.devices;"
var doc = nil
var ideClass =
Process:interpretPrintCmdLine 0x37c8708
arg this =
^^ The preceding error dump is for ERROR: Primitive 'none' failed.
Failed.
RECEIVER: nil
I am new to supercollider and I having a hard time figuring the reason for the error. Please suggest me how to resolve this.
Thanks in Advance.
I was having a similar problem (no output from supercollider at all, just complete and total silence), and this post ultimately led me to the right solution. I think it will be helpful to you and others.
From the ServerOptions documentation, I found that I could configure how SC talks to jack with environment variables.
In my case, I start scsynth with the relevant environment variables like so:
SC_JACK_DEFAULT_INPUTS="system:capture_1" SC_JACK_DEFAULT_OUTPUTS="system" scsynth -u 57110 &
It seems this can also be done from within sclang like so:
"SC_JACK_DEFAULT_INPUTS".setenv("system:capture_1");
"SC_JACK_DEFAULT_OUTPUTS".setenv("system");
In your case, where you are connecting to the wrong outputs, you might want to start scsynth like this:
SC_JACK_DEFAULT_OUTPUTS="system:playback_3,system:playback_4" scsynth -u 57110 &
Another alternative that will let you play with these connections and find what works for you is to use the jack_lsp, jack_connect, and jack_disconnect commands.
To see all of the ins/outs of your jack server as well as the current connections, run
jack_lsp -c
From your post, I think you will see something like
system:capture_1
SuperCollider:in_1
system:capture_2
SuperCollider:in_2
system:playback_1
SuperCollider:out_1
system:playback_2
SuperCollider:out_2
system:playback_3
system:playback_4
SuperCollider:out_1
system:playback_1
SuperCollider:out_2
system:playback_2
To make SuperCollider output to your headphones and speakers, you could conect out_1 and out_2 to playback_3 and playback_4 (assuming those are your headphones) like so:
jack_connect SuperCollider:out_1 system:playback_3
jack_connect SuperCollider:out_2 system:playback_4
To disconnect from the speakers, you could do
jack_disconnect SuperCollider:out_1 system:playback_1
jack_disconnect SuperCollider:out_2 system:playback_2
Run jack_lsp -c again to see if your system is setup how you want!
I had the same problem. I discovered the solution by using Catia from KXStudio. See Catia
Catia is a JACK Patchbay. (Other patchbays are available. QJackctl and Patchage are examples). On my system (Ubuntu 14.04 on a Dell Studio laptop), SuperCollider maps its first 4 outputs to the 4 system playbacks. The first 2 system playbacks are the speakers, system playbacks 3 and 4 are the headphones. By remapping out1 and out2 from SC to playback_3 and playback_4, I hear it through the headphones. So, get hold of a patchbay for JACK, and see what you see.
Hope this helps.
After struggling countless times with this issue I managed to get it working with:
Add your user to the audio linux group.
Use cadence to start jack
Additional resource that could be helpful: https://wiki.archlinux.org/index.php/JACK_Audio_Connection_Kit
Firstly: the big long error message saying "A primitive was not bound" is unpleasant but in this case it just means you typed the wrong command. I don't know where you got that command ServerOptions.devices from but it's just wrong. Maybe the message was intended to tell you to type s.options.device which is more sensible but it's NOT what you need to do. Forget that and forget that long error message.
Secondly: the message you see when you boot the server is good, it tells you that the server has booted and connected to jack. SuperCollider is happy. If you hear sound out of the speakers but not from the headphones (I take it you mean when you plug the headphones in!), this is NOT a supercollider problem but just a standard operating-system issue about setting the volume on your headphones.
It appears that you're using linux so run the command alsamixer in a terminal, that's a good way to check whether the headphone output is muted. Use man alsamixer to understand how to use it, if it's not familiar to you.

Stack overflow in release binary but not in Xcode-Debugger

My (Cocoa)-App runs perfectly fine when I start it from within Xcode. However when I archive / release it, that version will crash. The error reporter that pops open says:
[...]
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
[9082] stack overflow
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff944a7212 __pthread_kill + 10
1 libsystem_c.dylib 0x00007fff9290caf4 pthread_kill + 90
2 libsystem_c.dylib 0x00007fff92950e9e __abort + 159
3 libsystem_c.dylib 0x00007fff92951d17 __stack_chk_fail + 195
[...]
While it also gives me the line of code where execution stopped, this really does not help me as the exact same code path is executed in debug mode (but succeedes).
So I'm wondering: might it actually be that the stack sizes are different for a release and a debug version? And how big is the stack after all on a Mac (64 bit / Mountain Lion)? I'm not aware of putting insanely much data on the stack...
If I have too much data on the stack, what patterns would I need to avoid to reduce my stack load?
[Update]
ok, I got my App running by adding the -fno-stack-protector flag. (BTW: I'm compiling with LLVM)
Before that, I stepped through the crashing code line by line and found the following bahaviour which I don't understand:
the method foo(x) calls bacon(x). x is 8 and is handed from foo to bacon without modification. Yet when I step into bacon(x), x suddenly is 4295939448 (each time). If I set -fno-stack-protector the value is correct.
To my naive eyes, this looks as if the stack-protector sets the magic value 4295939448 somewhere in the stack and makes it read-only. And while my functions put their parameters on the stack, at some point parameter x happens to be put on that magic address and thus cannot be written (subsequent parameters seem to be written correctly). In my case x is a buffer length parameter, which naturally leads to a buffer-overflow and crash.
Does somebody have a deeper understanding of the stack-protector? Why is this happening? And in what cases is it safe and legal to disable the stack-protector and in what cases is it dangerous?
[Update 2: Original Code]
This method calls the other Decrypt below. stIVLen at that point is 8
BOOL CEracomSE::Decrypt(
PBYTE pMsg, size_t stLen,
const CSK* pKey /* = NULL */,
PBYTE pIV /* = NULL */, size_t stIVLen /* = 0 */,
FBM fbm /* = FBM_CBC */,
PADDING padding /* = NO_PADDING */
)
{
//stIVLen == 8
return Decrypt( (uint64_t)0, pMsg, stLen, pKey, pIV, stIVLen, fbm, padding );
}
When Decrypt is called stIVLen is 4295939448, the other parameter are still correct
BOOL CEracomSE::Decrypt(
uint64_t qwOffset,
PBYTE pMsg, size_t stLen,
const CSK* pKey /* = NULL */,
PBYTE pIV /* = NULL */, size_t stIVLen /* = 0 */,
FBM fbm /* = FBM_CBC */,
PADDING padding /* = NO_PADDING */
)
{
//stIVLen now is 4295939448
BYTE a_iv[16] = {0};
size_t a_iv_len;
BYTE a_key[32] = {0};
size_t a_key_len = 0;
size_t nBytes;
size_t nDataOffset;
size_t nRemainingData = stLen;
bool ret;
//[...]
}
I recently faced this situation with my app. I know its an old thread but responding anyways with the intent that someone else could benefit from the findings.
Passing -fno-stack-protector did solve the problem as suggested in the question. However, digging a little deeper we found that, changing all occurrences of literal array declaration to a longer declaration did solve the problem without passing the compiler flag.
so changing all occurrences of
#[#(1), #(2)]
to
[NSArray arrayWithObjects:#(1), #(2), nil]
May be its specific to our app only but hope it helps others as well.