Objective-C implementation of Shape Context algorithm (Image Matching)? - objective-c

There is a very cool sounding technique called Shape Context matching, which can be used in an Image Recognition application to match an "unknown image" against a known "image library." There are numerous descriptions of the concept documented on the web (mostly all variations of the same original paper), for example: http://www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html
I found a JAVA implementation and a MATLAB implementation of the algorithm described in the paper, but I cannot find an objective-c implementation. Anyone know if there is any objective-c code out there, anywhere, implementing these techniques? I sure would like to take advantage of it, rather than trying to write that stuff myself!

Here you can find an interesting c++ implementation (for non-commercial usage, didn't check it yet.. see the downloads):
http://www.umiacs.umd.edu/~zhengyf/PointMatching.htm

I'm currently searching for a Java implementation of the algorithm. Could you please provide a link to the implementation you found?
The original matlab code can be downloaded at:
www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html
I also found a C# implementation:
http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=7465&lngWId=10

Take a look at OpenCV. It is implemented in C so it can be used in obj-c pretty easily.

Related

When analyzing a binary compiled from Swift, is it possible to figure out the Swift method name for a function that has no symbol?

I'm new to disassembling and reverse engineering binaries, so forgive me if this question is nonsensical or impossible.
In the past when I've tried reverse engineering macOS binaries, analyzing the ones written in Objective-C yielded a lot of useful information, because generally all of the Objective-C classes and their method names were easily retrievable, making it a lot easier to figure out what any particular method did.
I'm trying to analyze a binary written in Swift (technically a combination of Swift and Objective-C), and most of the functions now have no symbol. There are some Objective-C methods that I can retrieve as usual, and a few functions that have a Swift-style mangled name, but nearly all of the rest have no symbol. I know a lot of those have to be Swift methods.
Is there anyway to figure out what this binary's Swift classes are and their associated methods like I can with Objective-C?
Using a tool like Hopper Disassembler reveals the mangled names of some Swift classes (usually a symbol like _TtC4Something25SomethingElse) and I can get a list of its instance variable names and their offsets, but no method names.
Note: the binary in question is an x64 macOS binary, not an iOS binary.
Usually reverse engineeing is the process of extracting meaningful constructs and descriptions from assembly. What you've done so far is usually only the first part of a "normal" reverse engineeing task.
This may sometimes be a tedious process, which involves mapping structures and understanding the meaning of functions directly from thier assembly code.
There are pleanty of reverse engineeing tutorials and other sources, and a good understanding of the relevant assembly language is required.
I really recommand this book (it's legally available online, original version is chm released by author) and this cannot easily be covered in a single SO question.
You might also want to get more specific help in the reverse engineeing SE beta.
I hope I pointed you in the right direction.

Objective-C standards document

I'm a C and C++ programmer trying to get started with Objective-C. I'm really bewildered, though, by the apparent total absence of a standards document for the language and standard library. I can understand that there's no ISO standard, but is there no reference document at all? And how is it that nobody seems very concerned about this state of affairs? (Admittedly, it's hard to Google for such a thing, because "reference", "document", and "standard" are all overloaded terms. So it's possible that I've just missed something critical.)
This question gets close to asking the same thing: Where can i find a document explaining how Objective-C is implemented and the only answer provided was "read this source code published by Apple which is pretty close to what their implementation did a few years ago, maybe".
This page: http://clang.llvm.org/docs/ObjectiveCLiterals.html includes a snippet of a formal grammar for Objective-C, but ironically it's in the context of describing a feature that Clang just went off and added on their own and that nobody else supports. There's another grammar here: http://www.omnigroup.com/mailman/archive/macosx-dev/2001-March/022979.html but it's more than 10 years old.
To narrow the question down to the barest minimum: I'd like to know what methods are guaranteed to be provided by "Object", and what the behavior of each method is. For other languages, this type of information is usually provided by something like this: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html
Unfortunately there is no Standard for ObjC as there is for C++ or C. Apple being the main user and driver behind the language, their compiler implementation (the ObjC bits of Clang) is the de facto Standard. Their old document (broken link) "The Objective-C Programming Language" was about as close as you got to a prose version, and it was nowhere near the precision of either of those other languages' Standards (and it tends to lag behind the compiler).
It may still be floating around on the web somewhere, but it is no longer up-to-date. "Programming with Objective-C" seems to be their intended replacement (but again, it's nothing like a standard).
Regarding your comment (10k link only) under Tim's deleted answer, the Cocoa root class is NSObject, and its interface is documented, but its source is not available. Note that the NSObject protocol is also an extremely important part of a Cocoa object's functionality. Apple's runtime is open-source,* and has a root class called Object, I assume for purposes of demonstration. It's not used in Cocoa programming.
You already know about all of this, of course. The direct answer to your question is, "there isn't one". Most of the syntax is the same as C, though, as bbum points out: Authoritative description of ObjectiveC string literals? (yes, I copy-pasted my comment from there into the beginning of this answer).
*Note that contrary to what you say in your question, this is the actual, up-to-date, runtime.
I think I understand your question correctly, so I will answer accordingly...
I highly recommend the documents in the Apple Developer Library. Here are a couple basic guides to get you started:
Concepts in Objective-C Programming
Programming with Objective-C
Cocoa Fundamentals Guide
iOS App Programming
The documents there are the definitive source for Objective-C and Cocoa best practices and coding standards. There are many more documents on a multitude of topics, so make sure to check that website out.
You also asked about how to know what methods are available for objects. To know that, you can check out the Class References.
For example:
NSObject Class Reference
The difference between the guides and the class references is that the guides are more about the concepts behind the code whereas the class references are a list of the methods and properties available for a class.
Hope this helped.
Found at least some of the language definitions of Objective-C, including syntax etc. (see link)
I'm just now where you have been 3 years ago (according to the date in your question): I'm starting to get into Objective-C, and I find it as well strange that there seems to be no reference manual, where I could for example look up the exact meaning and definition of syntax, keywords etc.
I've now discovered, that at least some of it can be found in a document which is related to cocoa (Cocoa Core Competencies). The link for example jumps to the definition of the keyword "#property".
In my POV this is not only relevant only specifically to Cocoa but is generally defining the Objective-C language extension of C. Thats why I wouldn't have searched for it in documents labled "Cocoa ".

Parsing Objective-C code for static analysis

I love static analysis and compile-time checks, almost to a fault, but most of my day job is in Objective-C. To resolve this tension, I'd like to be able to write my own analysis tools that I can run on my Objective-C projects.
But googling around the Internet suggests that people are having a hard time putting together a complete Objective-C grammar. One site basically recommends giving up.
I did find a grammar on the ANTLR website, but when I fired it up, I couldn't get it to parse anything at all. For example, it responded to the line:
void x();
with src/main/resources/somecode.m line 1:0 no viable alternative at input 'void'
:(
I took a closer look at the grammar and found the following disheartening disclaimer:
it's a work in progress, most of the .h file can be parsed
But I need something that can parse both interface and implementation.
Is there a complete Objective-C 2.0 grammar out there somewhere? I'd prefer something that can work with Scala (so anything Java compatible, like ANTLR, would be perfect), but at this point I'd be willing to adapt something designed for another parser toolkit.
As others mentioned, Clang would be the right solution. You can provide your own AST consumers, i.e. classes that will be invoked when going over the AST, leaving you not having to worry about parsing or messing with grammar.
Clang supports Objective-C in its entirety, and there's a lot of classes already in the static analyzer that you can model your own checks after. (in clang/lib/StaticAnalyzer/Checkers).
That directory contains a lot of static analyzer checkers, but you can also just create a normal AST consumer. Refer to http://code.google.com/p/chromium/wiki/WritingClangPlugins for more information.
Clang is a static analysis tool that has support for Objective-C. I've found it very useful in the past.
http://clang-analyzer.llvm.org/
clang is extensible; you can extend their existing static analysis or create your own. llvm / clang is architected as a series of libraries you can link to (dynamically or statically). A great starting point is the ARC (automatic reference counting) migrator library, which is responsible for statically analysing and rewriting objective-c code.
arcmt-test is a small example program that consumes the ARC migrator library.
You can use OCDepend, it's a static analysis tool based on Clang that simplifies managing Objective-C code quality and provides a highly flexible code query framework.

jGraphT for Objective C?

I'm looking for a Directed Acyclic Graph implementation in Objective C.
I've had enormous success with jGraphT in the Java space. I'm using a DirectedGraph to model a power subsystem, and now I need equivalent code for iPhone/iPad.
Does such a thing exist in an open source library? Or do I need to roll my own?
There's no available implementation in Objective C at present. However, this should be very helpful, particularly Mark Wukta's PASCAL implementation.
See
https://stackoverflow.com/questions/1284928/directed-graph-implementation-in-objective-c/13310549#13310549
AFAIK there is not Objective-C library for that. I needed a digraph and I forked Aaron Qian's digraph. Maybe add Tarjan's algorithm and you are almost there, but jgrapht is miles away in features.

calculus engine in vb?

is there an easy to use library or engine for .NET that does calculus?
I posted an early version of some code I used in one of my classes in an answer to this thread:
Generated methods for polynomial evaluation (my answer includes classes for symbolic differentiation)
If I know exactly what you're looking for, I could try to post an updated version.
Google is suggesting you look through Wikipedia's list of free libraries that can do automatic differentiation, and see if any have a .NET or COM wrapper. EDIT: High-Performance Mark has pointed out that it appears you need symbolic differentiation, in which case these libraries won't help.
If you are keen, you possibly could create a .NET wrapper for one of the C++ libraries.