Предотвращение столкновений с использованием OpenCV на iPad

Я работаю над проектом, в котором мне нужно реализовать предотвращение столкновений с использованием OpenCV. Это должно быть сделано на iOS (iOS 5 и выше подойдет).

Цель проекта: Идея состоит в том, чтобы установить iPad на приборной панели автомобиля и запустить приложение. Приложение должно захватывать кадры с камеры и обрабатывать их, чтобы определить, не столкнется ли автомобиль с каким-либо препятствием.

Я новичок в любой обработке изображений, поэтому я застрял на концептуальных уровнях в этом проекте.

Что я уже сделал:

Had a look at OpenCV and read about it on the net. Collision avoidance is implemented using Lukas-Kanade Pyramid method. Is this right?

Using this project as a starting point: http://aptogo.co.uk/2011/09/opencv-framework-for-ios/ It successfully runs on my iPad and capture functionality works as well, which means camera capture is well-integrated. I changed the processFrame implementation to try Optical Flow instead of Canny edge detection. Here is the function (incomplete yet).

    -(void)processFrame {
    int currSliderVal = self.lowSlider.value;
    if(_prevSliderVal == currSliderVal) return;
    cv::Mat grayFramePrev, grayFrameLast, prevCorners, lastCorners, status, err;

    // Convert captured frame to grayscale for _prevFrame
    cv::cvtColor(_prevFrame, grayFramePrev, cv::COLOR_RGB2GRAY);
    cv::goodFeaturesToTrack(grayFramePrev, prevCorners, 500, 0.01, 10);
    // Convert captured frame to grayscale for _lastFrame
    cv::cvtColor(_lastFrame, grayFrameLast, cv::COLOR_RGB2GRAY);
    cv::goodFeaturesToTrack(grayFrameLast, lastCorners, 500, 0.01, 10);

    cv::calcOpticalFlowPyrLK(_prevFrame, _lastFrame, prevCorners, lastCorners, status, err);
    self.imageView.image = [UIImage imageWithCVMat:lastCorners];
    _prevSliderVal = self.lowSlider.value;
}
Read about Optical Flow and how it is used (conceptually) to detect impending collision. Summary: If an object is growing in size, but moving towards any edge of the frame, then it is not a collision path. If an object is growing in size, but not moving towards any edge, then it is on collision path. Is this right? This project (http://se.cs.ait.ac.th/cvwiki/opencv:tutorial:optical_flow) appears to be doing exactly what I want to achieve. But I did not understand how it is doing so by reading the code. I cannot run it as I don't have a linux box. I read the explanation on this web-page, it seems to arrive at an homograph matrix. How is this result used in collision avoidance?

В дополнение к вышеупомянутым четырем упомянутым пунктам я прочитал намного больше об этой теме, но все еще не могу собрать все части вместе.

Вот мои вопросы (помните, я новичок в этом)

HOW is optical flow used to detect impending collision? By this I mean, supposing I'm able to get correct result from the function cv::calcOpticalFlowPyrLK(), how do I take it forward from there to detect impending collision with any object on the frame? Is it possible to gauge distance from the object we are most likely to collide with?

Is there a sample working project which implements this or any similar functionality that I can have a look at. I had a look at the project on eosgarden.com, but no functionality seemed to be implemented in it.

In the above sample code, I'm converting lastCorners to UIImage and I'm displaying that image on screen. This shows me an image which only has colored horizontal lines on the screen, nothing similar to my original test image. Is this the correct output for that function?

I'm having a little difficulty understanding the datatypes used in this project. InputArray, OutputArray etc are the types accepted by OpenCV APIs. Yet in processFrame function, cv::Mat was being passed to Canny edge detection method. Do I pass cv::Mat to calcOpticalFlowPyrLK() for prevImage and nextImage?

Заранее спасибо :)

Update: Нашел этот пример проекта (http://www.hatzlaha.co.il/150842/Lucas-Kanade-Detection-for-the-iPhone). Он не компилируется на моем Mac, но я думаю, что из этого у меня будет рабочий код для оптического потока. Но все же я не могу понять, как я могу обнаружить препятствующее столкновение от отслеживания этих точек. Если кто-то из вас может даже ответить на Qts. № 1, это будет очень полезно.

Update Похоже, оптический поток используется для расчета FoE (Focus of Expansion). Может быть несколько кандидатов в ФА. И используя FoE, TTC (Time To Collision) достигается. Мне не очень ясно в последней части. Но я пока прав?Does OpenCV implement FoE and/or TTC?

Ответы на вопрос(1)

Ваш ответ на вопрос