Ask Your Question

gfx's profile - activity

2019-08-05 12:01:58 -0600 received badge  Popular Question (source)
2018-03-12 02:59:32 -0600 received badge  Popular Question (source)
2018-02-19 23:47:37 -0600 commented question lock the mask on the selected area

tanks ... not usual to new taking algorithm ... i try it.

2018-02-19 23:46:55 -0600 edited question lock the mask on the selected area

lock the mask on the selected area I have a low quality video .... my intent is to bring a frame, manually draw a circle

2018-02-19 23:03:24 -0600 asked a question lock the mask on the selected area

lock the mask on the selected area I have a low quality video .... my intent is to bring a frame, manually draw a circle

2017-07-20 17:10:54 -0600 commented question opencv3.0 C++ Match Template mltiple item of same object crash after introduce new one

yes is 50 car .... ok thanks I try. mmm ... about use 3.2 last ... may be next week .... on my program i have a lot of features to change if upload opencv to last one ....

2017-07-20 03:31:13 -0600 commented question opencv3.0 C++ Match Template mltiple item of same object crash after introduce new one

you are in right ... Real Thanks. Nevere use Rect in these way ... you do an "and" of two rect in these way?

Ant how without using thresold trik or iterator (as my code do) these is an other way to identify multiple item of same object?

2017-07-20 03:15:21 -0600 commented question opencv3.0 C++ Match Template mltiple item of same object crash after introduce new one

ok ... jumping a number of frame = K works .... REAL SORRY K IS MEANS "ì" iterator in code posted.

but there are a better solution?

2017-07-20 03:01:02 -0600 commented question opencv3.0 C++ Match Template mltiple item of same object crash after introduce new one

Is there a way that you can not use the iterator "K"? I have already seen the thresold makeup but I did not manage to make good results. My is not a picture defined as the picture of a super mario bros screen.

2017-07-20 02:58:02 -0600 commented question opencv3.0 C++ Match Template mltiple item of same object crash after introduce new one

(more) ... for sure the Roi location error show when my hand "overlap" the rect that identify the targhet on video ... For sure the problem of Roi's incorrect location appears when my hand overlaps with the rectangles that identify the targhet ... I suppose I should remove the Roi under my hand before the error appears ... but maybe the right one Solution is jumping 50 frames or a number of frames = K ??

2017-07-20 02:49:48 -0600 commented question opencv3.0 C++ Match Template mltiple item of same object crash after introduce new one

yes you are in right these is an error but not the important one ... sorry my mistache not show the result error ... here the messages:

OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /home/gfx/opencv-3.0.0/modules/core/src/matrix.cpp, line 495
    terminate called after throwing an instance of 'cv::Exception'
      what():  /home/gfx/opencv-3.0.0/modules/core/src/matrix.cpp:495: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat
my video is tranform from cv::getPerspectiveTransform command ... I don't know if these is a problem ... (more)

2017-07-19 12:06:51 -0600 asked a question opencv3.0 C++ Match Template mltiple item of same object crash after introduce new one
case 16:{

dest_image.copyTo(carTmplt1);
dest_image.copyTo(carTmplt4);
double minVal; double maxVal, thresholdM = 0.9;;
cv::Point minLoc, maxLoc, matchLoc;
int match_method = CV_TM_CCORR_NORMED;
Size patchSize = Size(50, 50);

UserRectMask = Rect(DataRoiX1, DataRoiY1, DataRoiX4, DataRoiY4);

cvtColor(dest_image, imgHSV, CV_RGB2HSV);

inRange(imgHSV, Scalar(a,b,c), Scalar(a1,b1,c1), imgThresh);
imgThresh.copyTo(desTresh4);

cvtColor(carTmplt1, carTmplt2, CV_RGB2GRAY);

matchTemplate(carTmplt2, carTmplt, carTmplt3, match_method);
normalize(carTmplt3, carTmplt3, 0, 1, cv::NORM_MINMAX, -1, cv::Mat());

maskM = Mat::ones(carTmplt3.size(), CV_8UC1);

       for(int i=0; i<50; i++)
       {
           minMaxLoc(carTmplt3, NULL, NULL, NULL, &maxLoc, maskM);
           Rect bestMatch = Rect(maxLoc, patchSize);
           if((UserRectMask.contains(cv::Point(bestMatch.x, bestMatch.y))) && (UserRectMask.contains(cv::Point((bestMatch.x + bestMatch.height), (bestMatch.y + bestMatch.width))))){
               Mat roiM = maskM(bestMatch);
               roiM.setTo(0);


               if( match_method  == CV_TM_SQDIFF || match_method == CV_TM_SQDIFF_NORMED ) { matchLoc = minLoc;}
               else{ matchLoc = maxLoc;}

               cv::rectangle(carTmplt4, matchLoc, cv::Point(matchLoc.x + carTmplt.cols , matchLoc.y + carTmplt.rows), CV_RGB(255,0,0), 3);
               cv::floodFill(carTmplt4, matchLoc, cv::Scalar(0), 0, cv::Scalar(.1), cv::Scalar(1.));
           }


       }

These code works well ... and detect all 10-15 car in my video .... but if I introduce my hand in front of my camera the program crash ... if introduce my hand I obscured some car ... so I think the previous Roi was loose and maskM too .... there are a system to prevent these? or the only way is use one only frame every time the case:16 become true? Where is my error?

regards gfx

2017-07-18 16:06:21 -0600 commented question VideoCapture read non blocking?

not know at all python .. but i think if cap.open() first is needed ... any how normally the detection works in a separate thread ....

2017-07-18 16:00:55 -0600 commented question I want to detect the distance between camera and an object,dimensions of the object by using open cv?

not clear what you try to do. Is for drive a robot? there are other library specific for 3d spatial point detection (PLC) .... if you want to use opencv with only one camera, some math calculation after camera calibration is needed.... but not sure these work in every situation.

2017-07-14 12:19:59 -0600 commented answer How to find the exact colour range in HSV?

cvtColor(dest_image, imgHSV, CV_RGB2HSV); /dest_image = input/
inRange(imgHSV, Scalar(a,b,c), Scalar(a1,b1,c1), imgThresh); /* a,b,c, = rgb color 0 to 255, a1,b1,c1 is light par 0 to 255/
imgThresh.copyTo(desTresh4);
if( v1 == 0 ){ erosion_type = MORPH_RECT; }
else if( v1 == 1 ){ erosion_type = MORPH_CROSS; }
else if( v1 == 2) { erosion_type = MORPH_ELLIPSE; }
else{ erosion_type = MORPH_RECT; }
elementDilation = getStructuringElement( erosion_type, Size( 2n + 1, 2n+1 ), Point( n, n ) );
elementErosion = getStructuringElement( erosion_type, Size( 2h + 1, 2h+1 ), Point( h, h ) );
dilate( desTresh4, desTresh3, elementDilation ); / pus ... erode and dilate func/
erode( desTresh3, desTresh2, elementErosion );  /desTresh2 = output n & h only 1-3-5-7-9-11 value*/ 

2017-07-14 12:15:33 -0600 commented answer How to find the exact colour range in HSV?

mine it is a question but an answer in the same time .... here the code:

2017-07-12 10:12:03 -0600 commented question Descriptors/Features of non-textured parts


VideoCapture capture("input.avi");
    string window_name = "result";
    namedWindow(window_name, CV_WINDOW_AUTOSIZE);
    Mat frame;
    for (;;) {
        vector<point2f> corners;
        capture >> frame;
        if (frame.empty())
            break;
        cvtColor(frame,frame,CV_RGB2GRAY);
        goodFeaturesToTrack(frame, corners, cornerCount, qualityLevel,
                            minDistance, noArray(), blockSize,
                            useHarris);
        for (int i = 0; i < cornerCount; i++){
            float x = corners[i].x;
            float y = corners[i].y;
            circle(frame,Point(x,y),5,Scalar(255, 0, 0, 0),2,8,0);
        }
        imshow("result", frame);
        waitKey(10);
    }
    return 0;
}

2017-07-12 10:10:39 -0600 commented question Descriptors/Features of non-textured parts

int main() {
    int cornerCount = 100;
    double qualityLevel = 0.01;
    double minDistance = 5;
    int blockSize = 20;
    int useHarris = false;

2017-07-12 08:36:34 -0600 commented question Draw Rectangle around objects which not matching

subtract background for first, for second subtract all contour from your image .... the result is non matching object ... obviusly if background image != non maching ... so the background subtraction maybe a solution or not. Can you print an image? Or similar one?

2017-07-12 07:34:24 -0600 answered a question [Solved] Ubuntu 14 opencv3.0.0 Training your own detector | packtpub.com error ...

long story short .... as other similar thread on argument .... the file path was wrong ....

the path valid in every situation, TESTED ONLY ON UBUNTU (using gedit "classic" scheme colour+characters):

  1. /home/yourFolder/pos (folder of positives images)
  2. /home/yourFolder/neg (folder of negatives images)
  3. /home/yourFolder/positives.txt
  4. /home/yourFolder/cars.info
  5. /home/yourFolder/cars.vec
  6. /home/yourFolder/bg.txt
  7. /home/yourFolder/data (folder of result "xml" file)
  8. in my case: yourFolder = b/Scrivania

the erroneus PATH:

  1. inside positives.txt = pos/yourimage.png <--- these is right
  2. inside cars.info = pos/yourimage.png 1 0 0 100 40 <--- these is right
  3. inside bg.txt = neg/yourimage.png THESE IS ABSOLUTELY WRONG
  4. OTHER IS ALL RIGHT

THE RIGHT PATH INSIDE FILE:

  1. inside positives.txt = pos/yourimage.png <--- OK
    1. inside cars.info = pos/yourimage.png 1 0 0 100 40 <--- OK
    2. inside bg.txt = /home/yourFolder/neg/yourimage.png THESE RIGHT
    3. OTHER IS ALL RIGHT

so is possible to use the command as explain into tutorial and make the cascade ....

THE COMMAND:

  1. for make cars.info file:
    find /home/yourFolder/pos -name '*.pgm' -exec echo {} 1 0 0 100 40 \; > /home/yourFolder/cars.info
  2. for make bg.txt file:
    find /home/yourFolder/neg -iname '*.pgm' -exec echo {} \; > /home/yourFolder/bg.txt
  3. for make cars.vec:
    opencv_createsamples -info /home/yourFolder/pos/cars.info -numPos 550 -w 48 -h 24 -vec /home/yourFolder/cars.vec
  4. for traincascade:
    opencv_traincascade -data /home/yourFolder/data -vec /home/yourFolder/cars.vec -bg ~/home/yourFolder/bg.txt -numPos 500 -numNeg 500 -numStages 2 -w 48 -h 24 -featureType LBP

Problem Solved!

2017-07-12 05:41:28 -0600 commented question C++ opencv3 no ideas how to divide these thresholded image

bounding rect

for more precision the targhet not rotate ... so hinspired from Franz Ideas I find out 2 new solution: 1) the targhet is 4 product identical .... so there are a sort of "STEP" one from other ... finding max X pixel in these contour I can add 1/2 step for first time and after the 1/1 step and fin yn and yn+1 coord ... 2)I can draw a bounding rect, divide it on two different image and ... no this is not a good opportunity.

the green line is from bottom, the max x, the x + 1/2Step, the x+1/2Step+Step ... and so on ... the design is not well proportioned

2017-07-12 05:19:06 -0600 commented question C++ opencv3 no ideas how to divide these thresholded image

Thanks a lot ... a new ideas (for me is really new, never utilize).... the problem in these case not is more or less point, but the caos ...for find that contour I must use erode and dilate, PID control of light = instability of these way to find out somethings ... So i'm crunching something solider .... that's why i thought of a haar cascade .... although i have not been able to run opencv_traincascade app .... do you have any experience about it? Do you know why I get the error? I created a post on the subject ....

2017-07-12 05:06:10 -0600 commented question Descriptors/Features of non-textured parts

case(1) prospective changing is request for sure .... but is not but it is not compulsory to use it. So your case is for multiple detection? (More than one caliber one partially superimposed over each other?). If not considet to use a thresolded image as i suggest you. At last the mechanism is the same for all algorithm ... To find pixels of a certain color, close to pixels of another color with a certain pattern ....

2017-07-12 04:54:51 -0600 commented question OpenCV3 write text on video

why not use putText outside if statement in other if statement similar to these? (sorry in c++ langh)

    if((len(faces) > 0) && firstimeToWrite){
    cv::putText(img = frame, text = 'How are you', org = (int(frameWidth/2 - 20),int(frameHeight/2)), fontFace = cv::FONT_HERSHEY_DUPLEX, fontScale = 3, 
                color = (0, 255, 0));
 firstimeToWrite = false;
}
2017-07-12 04:50:19 -0600 commented question How to find the exact colour range in HSV?

in the same manner??

gfx

2017-07-12 04:48:04 -0600 edited question [Solved] QT5 opencv3.1 ubuntu 16.04 cv::destroyAllWindows

I have a Qt5 Gui app with some camera regulation & transform. For code semplicity I use imshow("mywin", myMatimage) for show every transform used. If all It is as desired, I save the sequence of transformation, convert cv::Mat into QImage and show the image/video onto QT5 gui. All ok but for close thw imshow windows, I must release their matimage (it is all ok again), but after these I must manually close the opencv opened windows because I'm not able to detect and close these.

For sure I can connect a bool var on every imshow command, and when I want to close the windows use an if statement on every bool var ... if(myboolvarMy1imshowWindows){ destroyWindows("windows_myboolvarMy1imshowWindows");}

but there are a more eleegant way to do these?

regards gfx

2017-07-12 04:46:47 -0600 answered a question [Solved] QT5 opencv3.1 ubuntu 16.04 cv::destroyAllWindows
namedWindow( "Display image", WINDOW_AUTOSIZE ); 
imshow( "Display image", image );

If I use both commands instead of imgshow only you can use

destroyWindows("Display image")

with success... so there are no issue about destroyWindows.

gfx

2017-07-12 01:59:46 -0600 commented question Descriptors/Features of non-textured parts

..... then using find contour for find all contour in your image .... the metal of caliber it must be white, so you can find the long rectangle contour result from it, for these you can use drawboundingrect. You can filter the contour by the lenght of side of your boundingrect that you can find. As I can see only one long boundingrect there are on the image ....

the shape of blades is more difficult in these way ... but with a good threshold operation you can obtain the good quality of blades shape .... you can use bitwise operation to compare a "sample" shape with yours threshold shape ... for rotation you can use the long bounging rect previously obtained ... so you can rotate correctly your "red sample shape" using bitwise_and and control if there are more "red" then white

regards gf

2017-07-12 01:54:39 -0600 commented question Descriptors/Features of non-textured parts

in the image there area a caliber .... case (1): you want detect a caliber in any situation (light, place, colour background, more than one caliber etc etc...) or , case (2):, you want know if in a box there are a caliber? case (1) -> cascade classifier .... In these day i try to work with it for first time in my life on opencv3 ... with some trouble, because the opencv_traincascade seems not work well (for sure I make something wrong). case (2) -> the best way and faster is threshold the image with these code:

cvtColor(dest_image, imgHSV, CV_RGB2HSV);
dest_image.copyTo(cdst);
inRange(imgHSV, Scalar(a,b,c), Scalar(a1,b1,c1), imgThresh); /* a,b,c is int from 0 to 255 rgb colour... a1,b1,c1 is int from 0 to 255 hsv var or light condition*/ 

then using find contour

2017-07-12 01:37:06 -0600 commented question How can I detect the color of a certain portion of an image if I know the coordinates of this portion as a rectangle?

or you can use a Mask to delete everything from the image except what you want it to remain within your rectangle...

    cv::Mat in_mat;   // your image
cv::Mat mask_mat = cv::zeros(in_mat.size(), CV_8UC1); // an image with your rectangle same size as in_mask but b/w
cv::Mat masked_mat = cv::zeros(in_mat.size(), CV_8UC3); // an image with your rectangle same size as in_mask
cv::Mat out_mat = cv::zeros(in_mat.size(), CV_8UC3);  // output image same size of in_mat



mask_matrectangle(mask_mat, (yourIntX1, yourIntY1), (yourIntX2, yourIntY2), (255, 255, 255), -1)

masked_mat = cv::bitwise_and(in_mat, mask_mat)
in_mat.copyTo(out_mat, masked_mat);

if(!out_mask.empty()){
imgshow("your result of colur masked image", out_mask);
}

gfx

2017-07-11 13:30:32 -0600 asked a question [Solved] Ubuntu 14 opencv3.0.0 Training your own detector | packtpub.com error ...

As a title, for first time in my life I try to use a cascade classifier ... first step: from mpg4 grab from camera, obtain 150 png image of my targhet ... well cropped, with my targhet oriented in different ways and with different type of light intensity .... In the same manner obtain 800 image of background ... then I try make all step of the tutorial for obtain my detector... but nothing: when use opencv_traincascade app I obtain only these error ->

Train dataset for temp stage can not be filled. Branch training terminated.
Cascade classifier can't be trained. Check the used training parameters.

So After some experiment, as suggest from here packpub tutorial I downloaded from here UIUCI DataCar the data folder, then:

  1. copy all pos image from download/CarData/TrainImages to /home/b/Scrivania/pos ..
  2. copy all neg image from download/CarData/TrainImages to /home/b/Scrivania/neg ..
  3. use "find" command to make /home/b/Scrivania/positives.txt file
  4. use "find" command to make /home/b/Scrivania/bg.txt file
  5. copy/paste/rename /home/b/Scrivania/positives.txt into /home/b/Scrivania/car.info & add " 1 0 0 100 40" after ".pgm"
  6. opencv_createsamples -info /home/b/Scrivania/cars.info -num 550 -w 48 -h 24 -vec /home/b/Scrivania/cars.vec
  7. verify the .vec file ... seems all ok ..
  8. opencv_traincascade -data /home/b/Scrivania/data -vec /home/b/Scrivania/cars.vec -bg /home/Scrivania/b/Scrivania/bg.txt -numStages 10 -nsplits 2 -minhitrate 0.999 -maxfalsealarm 0.5 -numPos 500 -numNeg 500 -w 48 -h 24
  9. obtain the error exactly as my image, folder and file ... the error :
  10. Train dataset for temp stage can not be filled. Branch training terminated. Cascade classifier can't be trained. Check the used training parameters.

At this point I hope that everything depends on the fact that the tutorial refers to opencv2.4 and I use opencv3.0.0 ... so what are the points I'm wrong??

regards gfx

2017-07-11 13:04:05 -0600 commented question C++ opencv3 no ideas how to divide these thresholded image

may be and not try ... you have understand well my problem ... but not sure is possible obtain some usable angle point ... any how thanks. For first time in my life for solve these I try to use cascade classifier ... after a day spent for nothing obtain I try to use the DataCar illinois database for make my first experiment ...using these tutorial but I obtain only the same error as with my .vec, .info and bg.txt file ... `mode: BASIC

===== TRAINING 0-stage ===== <begin pos="" count="" :="" consumed="" 500="" :="" 500="" train="" dataset="" for="" temp="" stage="" can="" not="" be="" filled.="" branch="" training="" terminated.="" cascade="" classifier="" can't="" be="" trained.="" check="" the="" used="" training="" parameters.="" `="" ubuntu="" 14="" kernel="" 4.0="" opencv="" 3.0="" ...="" but="" for="" these="" open="" a="" new="" <="" p="">

regards gfx