| 53 | } |
| 54 | |
| 55 | bool IPLOpticalFlow::processInputData(IPLData* data, int, bool useOpenCV) |
| 56 | { |
| 57 | IPLImage* image = data->toImage(); |
| 58 | |
| 59 | int width = image->width(); |
| 60 | int height = image->height(); |
| 61 | int progress = 0; |
| 62 | int maxProgress = ((image->type() == IPL_IMAGE_COLOR)? 9 : 8)*height; |
| 63 | |
| 64 | _keypoints = new IPLKeyPoints(); |
| 65 | |
| 66 | // get properties |
| 67 | int algorithm = getProcessPropertyInt("algorithm"); |
| 68 | double threshold = getProcessPropertyDouble("threshold"); |
| 69 | bool nonmaxSuppression = getProcessPropertyBool("nonmaxSuppression"); |
| 70 | |
| 71 | notifyProgressEventHandler(-1); |
| 72 | |
| 73 | // Obtain first image |
| 74 | if(_image_prev.cols == 0) |
| 75 | _image_prev = image->toCvMat(); |
| 76 | //cvtColor(image->toCvMat(), _image_prev, CV_BGR2GRAY); |
| 77 | |
| 78 | //cvtColor(image->toCvMat(), _image_next, CV_BGR2GRAY); |
| 79 | _image_next = image->toCvMat(); |
| 80 | |
| 81 | cv::Mat flow; |
| 82 | |
| 83 | cv::optflow::calcOpticalFlowSF(_image_prev, _image_next, flow, 3, 2, 4); |
| 84 | |
| 85 | flow *= 10; |
| 86 | |
| 87 | cv::Mat planes[2]; |
| 88 | cv::split(flow, planes); |
| 89 | |
| 90 | _image_next.copyTo(_image_prev); |
| 91 | |
| 92 | delete _previewX; |
| 93 | _previewX = new IPLImage(planes[0]); |
| 94 | delete _previewY; |
| 95 | _previewY = new IPLImage(planes[1]); |
| 96 | |
| 97 | return true; |
| 98 | } |
| 99 | |
| 100 | IPLData* IPLOpticalFlow::getResultData( int index ) |
| 101 | { |