Ask Your Question

Stoerakustik's profile - activity

2017-07-27 04:30:28 -0600 commented answer Not understanding how calcOpticalFlowPyrLK outputs found points

i appreciate your answer, thank you!

2017-07-25 11:30:15 -0600 asked a question Not understanding how calcOpticalFlowPyrLK outputs found points

im not quite sure how to understand calcOpticalFlowPyrLK.

If im giving in a picture a with features fa on in also as a picture b, is it correct, that the feature list fb is always as big as fa? and i can figure out which features actually have been tracked by going though the "status" output looking for when it is 1?

so if the 3rd status uchar is 1 then this means that the position of the 3rd feature of fa in picture a is the position of the 3rd feature in fb in picture b

what is filled in fb if there is not a 1 in the status list for the corresponding feature?

2017-07-25 06:39:38 -0600 received badge  Organizer (source)
2017-07-25 06:38:17 -0600 asked a question stuck in calcopticalflowpyrlk

hello everyone,

Im stuck in a calcopticalflowpyrlk-call, my pc wont just continue to proceed with the program but instead be at around 50% cpu load and not going on.

i call the calcopticalflowpyrlk twice, because i have two cameras i want to track persons on. the first camera works just fine but in the second call of calcopticalflowpyrlk for camera 2 nothing happens....

persons_vector[i].corner_image_cam1/2 contains the old image of a person tracked before persons_vector[i].corners_cam1/2 contains the corners that are meant to be tracked.

            int winsize = 10;
            int level = 5;
            std::vector<uchar> status;
            std::vector<float> error;
            int flags =0;
            double minEigThreshold=1e-4;
            std::vector<std::vector<cv::Point2f> > allcorners_tracked;
            int found_corners_in_rect_cam1_number = -1;
            int found_corners_in_rect_cam2_number = -1;


            //checking if the already build persons appear in new image
            for(int i=0; i<persons_vector.size(); i++)
            {
                //try to track as much corners of each person onto the new image for cam1
                int tracked_features_count = 0;

                std::vector<cv::Point2f> tracked_features;

                std::cout << "vorlk_cam1" << std::endl;
                std::cout << persons_vector[i].corners_cam1.size() << std::endl;

                cv::calcOpticalFlowPyrLK(persons_vector[i].corner_image_cam1,cv_ptr_mono_features_cam1->image, persons_vector[i].corners_cam1, tracked_features, status, error, cvSize(winsize,winsize),
                level, cvTermCriteria( CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 20, .3 ), flags, minEigThreshold );

                std::cout << "nachlk_cam1" << std::endl;

                //if enough corners were found - check if the corners lie in one of the Rects, that found a person inside the borders.
                for (int n=0; n<status.size(); n++)
                {
                    if (status[n] == 1)
                    tracked_features_count++;
                }
                //at least 80% of the corners have to be tracked
                if(tracked_features_count >= 0.8*persons_vector[i].corners_cam1.size())
                {
                    for(int j=0; j<found_persons_inborder_cam1.size();j++)
                    {
                        cv::Rect scaled_rect;
                        scaled_rect.x = found_persons_inborder_cam1[j].x * factor_width;
                        scaled_rect.y = found_persons_inborder_cam1[j].y * factor_height;
                        scaled_rect.width = found_persons_inborder_cam1[j].width * factor_width;
                        scaled_rect.height = found_persons_inborder_cam1[j].height * factor_height;

                        if(scaled_rect.x< 0)
                        {
                            scaled_rect.x = 0;
                        }

                        if(scaled_rect.height < 0)
                        {
                            scaled_rect.height = 0;
                        }

                        if((scaled_rect.x + scaled_rect.width) > (cv_ptr_mono_features_cam1->image.size().width))
                        {
                            scaled_rect.width = cv_ptr_mono_features_cam1->image.size().width - scaled_rect.x ;
                        }

                        if((scaled_rect.y + scaled_rect.height) > (cv_ptr_mono_features_cam1->image.size().height))
                        {
                            scaled_rect.height = cv_ptr_mono_features_cam1->image.size().height - scaled_rect.y;
                        }

                        int tracked_features_inside_borders = 0;

                        for(int m=0; m<tracked_features.size(); m++)
                        {
                            if ((scaled_rect.x <= tracked_features[m].x) && (tracked_features[m].x<= (scaled_rect.x+scaled_rect.width))&&(scaled_rect.y <= tracked_features[m].y) && (tracked_features[m].y<= (scaled_rect.y+scaled_rect.height)))
                            {
                            tracked_features_inside_borders++;
                            }
                        }

                        //if a rect is found with enough corner points
                        //update image of person
                        //update position to person
                        //update corners to person
                        //update stale counter of person
                        //update rect of person
                        if (tracked_features_inside_borders>20)
                        {


                            //crop the image and the mask for feature detection to the size of the rect, the person was found in
                            cv::Mat cropped_image = cv_ptr_mono_features_cam1->image;
                            cropped_image = cropped_image(cv::Rect(scaled_rect.x, scaled_rect.y, scaled_rect.width, scaled_rect.height));
                            cv::Mat mask = cv_ptr_mono_background_cam1->image;
                            mask = mask(cv::Rect(scaled_rect.x, scaled_rect.y, scaled_rect.width, scaled_rect.height));

                            //track new good features inside the new assigned rect of the person
                            cv::goodFeaturesToTrack( cropped_image, corners, maxCorners, qualityLevel, minDistance, mask, blockSize, useHarrisDetector, k );

                            //remapping features on the uncropped picture
                            for (int s=0; s<corners ...
(more)
2017-03-23 10:34:39 -0600 asked a question opencv2/core/core.hpp not found after System update

after a system update i get an error while catkin_make-ing.

In file included from /home/alexander/git/human_detector/catkin_ws/src/human_detector/src/background.cpp:3:0: /opt/ros/kinetic/include/cv_bridge/cv_bridge.h:43:33: fatal error: opencv2/core/core.hpp: Datei oder Verzeichnis nicht gefunden (No such file or directory) compilation terminated.

get this for every file i included cv_bridge....

I am working with ROS kinetic on ubuntu 16.04