Friday, April 29, 2011

ASIFormDataRequest, binary data, and NSURL

In the previous post, i'd mentioned bout the ASIHTTPRequest by http://allseeing-i.com.  It is beautifully done and i urge you to grab that on GitHub if your cocoa development has req/resp to/fro a http server.

As a small note, if you do tend to 'upload' binary data with ASIFormDataRequest, and your binary data is dynamically created and stored in, for example, a tmp folder, noted as an NSURL.

These lines of code might save you a few minutes.

NSURL* url = ....;
[request setFile: [url relativePath] forKey: @"somePostKey"];
[request startSynchronous]; //or async.

re: IOS ASIHTTPRequest

http://allseeing-i.com/ASIHTTPRequest/How-to-use

Five Stars for the above link!!!

Tuesday, April 19, 2011

Monday, April 18, 2011

Useful Links:
1) http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/CoreApplication/CoreApplication.html

2) http://iosfeatures.blogspot.com/




Application life cycle


Table 2-3  Application states
State
Description
Not running
The application has not been launched or was running but was terminated by the system.
Inactive
The application is running in the foreground but is currently not receiving events. (It may be executing other code though.) An application usually stays in this state only briefly as it transitions to a different state. The only time it stays inactive for any period of time is when the user locks the screen or the system prompts the user to respond to some event, such as an incoming phone call or SMS message.
Active
The application is running in the foreground and is receiving events.
Background
The application is in the background and executing code. Most applications enter this state briefly on their way to being suspended. However, an application that requests extra execution time may remain in this state for a period of time. In addition, an application being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see “Executing Code in the Background.”
The background state is available only in iOS 4 and later and on devices that support multitasking. If this state is not available, applications are terminated and moved to the not-running state instead.
Suspended
The application is in the background but is not executing code. The system moves an application to this state automatically and at appropriate times. While suspended, an application is essentially freeze-dried in its current state and does not execute any code. During low-memory conditions, the system may purge suspended applications without notice to make more space for the foreground application.
The suspended state is available only in iOS 4 and later and on devices that support multitasking. If this state is not available, applications are terminated and moved to the not-running state instead.
To facilitate movement between these transitions, the system calls the following methods of your application delegate.
Figure 2-3  Launching into the active state


Figure 2-4  Moving from the foreground to the background

igure 2-5  Handling application interruptions (such as SMS, phone call etc..)

Figure 2-6  Transitioning from the background to the foreground

Monday, April 11, 2011

OSX Term + OpenCV + Alchemy SWC , Compilation I

, This should be it.

alc-on; gcc `pkg-config --cflags opencv` `pkg-config --libs opencv`-swc -o sample.swc sample.c; alc-off;

OSX Terminal + OpenCV

Very easy setup but took me sometime to follow
Requirements
MacPorts ready
~/.profile ready

Getting the Package 
(http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port)

sudo port selfupdate

sudo port install opencv

It will take some time for those installations.

Compiling
http://opencv.willowgarage.com/wiki/CompileOpenCVUsingLinux
1) put

PKG_CONFIG_PATH=/where/you/have/installed/opencv/lib/pkgconfig
export PATH=$PATH:PKG_CONFIG_PATH

in your ~/.profile
2) > source ~/.profile
3) > pkg-config --cflags opencv (should return the include paths to opencv)
4) To compile ur codes

gcc `pkg-config --cflags opencv` `pkg-config --libs opencv` -o my-opencv-prgm my-opencv-prgm.c


This should be it!

Sunday, April 3, 2011

Flex + Camera Capture (Entry-Level)

Below please find the simplest set of codes for snapping what's been fed from your camera.


<s:application minheight="600" minwidth="955" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:script>

</fx:script>
<fx:declarations>

</fx:declarations>

<mx:videodisplay creationcomplete="videoDisplay_creationCompleteHandler(event)" height="320" id="videoDisplay" width="480" x="0" y="0" />
<mx:button click="snapshotBtn_clickHandler(event)" id="snapshotBtn" x="0" y="330"/>
<mx:image id="myImg" x="490" y="0"/>

</s:application>