Q:

using opencv features2d on iPhone

I'm trying to use feature detection via OpenCV on iOS and I'm running into a conundrum:
features2d relies on highgui
highgui can't be built on iOS (or at least not that I can figure out).
This leads me to believe: features2d just can't be used on iOS without rewriting the module to remove the calls to cvSaveImage() and cvLoadImage(). Is this wrong? Anyone run into this and solved it?

A:

You are taking the wrong aproach, you dont need highgui since that library is only ment to make it easier for you to handle the results of your processing, you can simply do those steps manually.
for example, consider this HOG example:
#include <iostream>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>

int
main(int argc, char *argv[])
{
  const char *imagename = argc > 1 ? argv[1] : "../../image/pedestrian.png";
  cv::Mat img = cv::imread(imagename, 1);
  if(img.empty()) return -1; 

  cv::HOGDescriptor hog;
  hog.setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector());

  std::vector<cv::Rect> found;
  // 画像，検出結果，閾値（SVMのhyper-planeとの距離），
  // 探索窓の移動距離（Block移動距離の倍数），
  // 画像外にはみ出た対象を探すためのpadding，
  // 探索窓のスケール変化係数，グルーピング係数
  hog.detectMultiScale(img, found, 0.2, cv::Size(8,8), cv::Size(16,16), 1.05, 2);

  std::vector<cv::Rect>::const_iterator it = found.begin();
  std::cout << "found:" << found.size() << std::endl;
  for(; it!=found.end(); ++it) {
    cv::Rect r = *it;
    // 描画に際して，検出矩形を若干小さくする
    r.x += cvRound(r.width*0.1);
    r.width = cvRound(r.width*0.8);
    r.y += cvRound(r.height*0.07);
    r.height = cvRound(r.height*0.8);
    cv::rectangle(img, r.tl(), r.br(), cv::Scalar(0,255,0), 3);
  }

  // 結果の描画
  cv::namedWindow("result", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO);
  cv::imshow( "result", img );    
  cv::waitKey(0);
}

it is made for a non iOS enviroment, however you can simply replace all highgui calls for 
native iOS stuff. 
You can get a very good image handling for opencv library from here:
http://aptogo.co.uk/2011/09/opencv-framework-for-ios/
so what you should really care about in that code is just this part:
  cv::HOGDescriptor hog;
  hog.setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector());

  std::vector<cv::Rect> found;
  // 画像，検出結果，閾値（SVMのhyper-planeとの距離），
  // 探索窓の移動距離（Block移動距離の倍数），
  // 画像外にはみ出た対象を探すためのpadding，
  // 探索窓のスケール変化係数，グルーピング係数
  hog.detectMultiScale(img, found, 0.2, cv::Size(8,8), cv::Size(16,16), 1.05, 2);

  std::vector<cv::Rect>::const_iterator it = found.begin();
  std::cout << "found:" << found.size() << std::endl;
  for(; it!=found.end(); ++it) {
    cv::Rect r = *it;
    // 描画に際して，検出矩形を若干小さくする
    r.x += cvRound(r.width*0.1);
    r.width = cvRound(r.width*0.8);
    r.y += cvRound(r.height*0.07);
    r.height = cvRound(r.height*0.8);
    cv::rectangle(img, r.tl(), r.br(), cv::Scalar(0,255,0), 3);
  }

For a BRIEF:
// You get your img into a cv mat from the uiimage or whatever.

  cv::Mat gray_img;
  cv::cvtColor(img, gray_img, CV_BGR2GRAY);
  cv::normalize(gray_img, gray_img, 0, 255, cv::NORM_MINMAX);

  std::vector<cv::KeyPoint> keypoints;
  std::vector<cv::KeyPoint>::iterator itk;
  cv::Mat descriptors;

  //
  // threshold=0.05, edgeThreshold=10.0
  cv::SiftFeatureDetector detector(0.05,10.0);
  detector.detect(gray_img, keypoints);
  // Brief に基づくディスクリプタ抽出器
  cv::BriefDescriptorExtractor extractor;
  cv::Scalar color(50,50,155);
  extractor.compute(gray_img, keypoints, descriptors);

  // 32次元の特徴量 x keypoint数
  for(int i=0; i<descriptors.rows; ++i) {
    cv::Mat d(descriptors, cv::Rect(0,i,descriptors.cols,1));
    std::cout << i << ": " << d << std::endl;
  }

And you have your result.

