Ask Your Question

imran's profile - activity

2020-10-28 04:19:00 -0600 received badge  Nice Question (source)
2020-09-16 07:46:18 -0600 received badge  Nice Question (source)
2019-09-11 01:45:19 -0600 received badge  Famous Question (source)
2019-04-18 11:49:00 -0600 received badge  Famous Question (source)
2018-09-13 14:53:42 -0600 received badge  Great Question (source)
2018-08-14 13:46:48 -0600 received badge  Good Question (source)
2018-05-14 11:40:47 -0600 received badge  Enlightened (source)
2018-05-14 11:40:47 -0600 received badge  Good Answer (source)
2018-05-04 11:33:04 -0600 received badge  Notable Question (source)
2017-03-12 09:47:27 -0600 received badge  Popular Question (source)
2015-09-28 16:40:47 -0600 received badge  Notable Question (source)
2015-07-02 20:40:47 -0600 received badge  Popular Question (source)
2015-04-15 18:48:05 -0600 received badge  Nice Question (source)
2015-04-08 09:16:20 -0600 received badge  Famous Question (source)
2015-03-11 12:51:20 -0600 received badge  Taxonomist
2015-02-17 22:29:09 -0600 received badge  Famous Question (source)
2014-12-09 14:03:25 -0600 marked best answer Colour Quantization

Does anyone know if there are any Colour Quantization (Colour Reduction) methods in OpenCV?

If so, could you please guide me to where it is? Or anyone else that has implemented it using OpenCV?

2014-12-09 13:54:02 -0600 marked best answer Using Hue and Saturation to calculate Backprojection of an object

In OpenCV it is possible to calculate the backprojection of a selected area using only the Hue component in the HSV image (CamSHIFT example). I am trying to do the same thing but using both the Hue and Saturation components to compute the backprojection. I am not sure whether I am doing it correctly. Below is my code,

The functions that I am not to sure about are

  • int ch[] = { 0,0, 1,0}; // here from what I understand, for the variable fromTo needed in the mixChannels function, does this hsv[0]->hue[0], hsv[0]->saturation[1]
  • mixChannels(&hsv, 1, out, 2, ch, 2); // from what I understand should split, hue and saturation from hsv
  • calcHist(planes[1], 1, 0, maskroi, hist, 1, hdims, ranges);

If someone has done something similar, could you please advise.

\\code

Mat backProjectObject(Mat frame, Point pnt){

   int hsize = 16, ssize = 16;
   int hdims[] = { hsize, ssize };
   float h_ranges[] = { 0,180 };
   float s_ranges[] = { 0,255 };
   const float* ranges[] = { h_ranges, s_ranges };

   Mat hsv, hue, saturation, mask, histimg = Mat::zeros(200, 320, CV_8UC3);
   MatND hist, backproj;

   Rect selection;
   int vmin = 10, vmax = 256, smin = 30;

   cvtColor(frame, hsv, CV_BGR2HSV);

   selection.x = pnt.x; //selected center for the area
   selection.y = pnt.y; //selected center for the area
   selection.width = 20; //selected center for the area
   selection.height = 20; //selected center for the area

   selection &= Rect(0, 0, frame.cols, frame.rows);

   int _vmin = vmin, _vmax = vmax;

   inRange(hsv, Scalar(0, smin, MIN(_vmin,_vmax)), Scalar(180, 256, MAX(_vmin, _vmax)), mask);
   hue.create(hsv.size(), hsv.depth());
   saturation.create(hsv.size(), hsv.depth());
   Mat out[] = { hue, saturation };
   int ch[] = { 0,0, 1,0};
   Mat planes[2][2];

   mixChannels(&hsv, 1, out, 2, ch, 2);

   planes[0][0] = hue; 
   planes[0][1] = saturation;

   Mat roi1(hue, selection), roi2(saturation, selection), maskroi(mask, selection);

   planes[1][0] = roi1; //selected template
   planes[1][1] = roi2; //selected template        

   calcHist(planes[1], 1, 0, maskroi, hist, 1, hdims, ranges);
   normalize(hist, hist, 0, 255, CV_MINMAX);

   calcBackProject(planes[0], 1, 0, hist, backproj, ranges);
   backproj &= mask;
   threshold( backproj, backproj, 250, 255,0 );

   return backproj;

}

2014-12-09 13:44:43 -0600 marked best answer Counting the number of colours in an image

Can someone guide me on a way to count the number of colours in an image? My idea is to take an RGB image, convert it to HSV and then split the channels so I only have the Hue channel. Then within the Hue channel, I would like to know if there are for example 50 pixels that have the value 123 and 25 pixels with the value 160 and so forth. Any guidance please on the methods I can use to do this?

The reason for doing this is, given 2 images A & B. I will have the number of colours of each image, then compare whether the two images share the same number of colours. For example, both images have 50 pixels with the value 123 etc.

Thank you in advance

2014-12-09 13:15:55 -0600 marked best answer Compiling freak_demo.cpp - error

Has anyone been able to compile freak_demo.cpp in OpenCV 2.4.2? Everything else compiles besides this. I get this error,

compiling freak_demo.cpp
freak_demo.cpp: In function ‘int main(int, char**)’:
freak_demo.cpp:93:5: error: ‘FREAK’ was not declared in this scope
freak_demo.cpp:93:11: error: expected ‘;’ before ‘extractor’
freak_demo.cpp:110:5: error: ‘extractor’ was not declared in this scope

This is what I get after compiling the samples/cpp/ folder:

compiling *.c
compiling 3calibration.cpp
compiling OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp
compiling OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp
compiling bagofwords_classification.cpp
compiling bgfg_segm.cpp
compiling brief_match_test.cpp
compiling build3dmodel.cpp
compiling calibration.cpp
compiling calibration_artificial.cpp
compiling camshiftdemo.cpp
compiling chamfer.cpp
compiling connected_components.cpp
compiling contours2.cpp
compiling convexhull.cpp
compiling cout_mat.cpp
compiling delaunay2.cpp
compiling demhist.cpp
compiling descriptor_extractor_matcher.cpp
compiling detection_based_tracker_sample.cpp
compiling detector_descriptor_evaluation.cpp
compiling detector_descriptor_matcher_evaluation.cpp
compiling dft.cpp
compiling distrans.cpp
compiling drawing.cpp
compiling edge.cpp
compiling em.cpp
compiling facerec_demo.cpp
facerec_demo.cpp: In function ‘int main(int, const char**)’:
facerec_demo.cpp:136:12: error: ‘class cv::FaceRecognizer’ has no member named ‘set’
facerec_demo.cpp:143:30: error: ‘class cv::FaceRecognizer’ has no member named ‘getMat’
facerec_demo.cpp:145:20: error: ‘class cv::FaceRecognizer’ has no member named ‘getMat’
compiling fback.cpp
compiling ffilldemo.cpp
compiling filestorage.cpp
filestorage.cpp: In function ‘int main(int, char**)’:
filestorage.cpp:165:52: error: ‘MEMORY’ is not a member of ‘cv::FileStorage’
filestorage.cpp:175:51: error: ‘MEMORY’ is not a member of ‘cv::FileStorage’
filestorage.cpp:175:73: error: ‘FORMAT_YAML’ is not a member of ‘cv::FileStorage’
filestorage.cpp:181:31: error: ‘class cv::FileStorage’ has no member named ‘releaseAndGetString’
compiling fitellipse.cpp
compiling freak_demo.cpp
freak_demo.cpp: In function ‘int main(int, char**)’:
freak_demo.cpp:93:5: error: ‘FREAK’ was not declared in this scope
freak_demo.cpp:93:11: error: expected ‘;’ before ‘extractor’
freak_demo.cpp:110:5: error: ‘extractor’ was not declared in this scope
compiling gencolors.cpp
compiling generic_descriptor_match.cpp
compiling grabcut.cpp
compiling houghcircles.cpp
compiling houghlines.cpp
compiling hybridtrackingsample.cpp
compiling image.cpp
compiling imagelist_creator.cpp
compiling inpaint.cpp
compiling kalman.cpp
compiling kmeans.cpp
compiling laplace.cpp
compiling latentsvm_multidetect.cpp
compiling letter_recog.cpp
compiling linemod.cpp
compiling lkdemo.cpp
compiling logpolar_bsm.cpp
compiling matcher_simple.cpp
compiling matching_to_many_images.cpp
compiling meanshift_segmentation.cpp
compiling minarea.cpp
compiling morphology2.cpp
compiling multicascadeclassifier.cpp
compiling opencv_version.cpp
compiling openni_capture.cpp
compiling peopledetect.cpp
compiling phase_corr.cpp
compiling point_cloud.cpp
compiling points_classifier.cpp
compiling retinaDemo.cpp
compiling rgbdodometry.cpp
compiling segment_objects.cpp
compiling select3dobj.cpp
compiling squares.cpp
compiling starter_imagelist.cpp
compiling starter_video.cpp
compiling stereo_calib.cpp
compiling stereo_match.cpp
compiling stitching.cpp
compiling stitching_detailed.cpp
compiling video_dmtx.cpp
compiling video_homography.cpp
compiling videostab.cpp
compiling watershed.cpp
2014-12-09 13:05:48 -0600 marked best answer Active Contours in OpenCV

Can someone tell me if Active Contours is implemented in OpenCV? I can't seem to find it in the reference manual. I think it was implemented in the previous versions of OpenCV under cvSnakeImage but I don't seem to find anything in the current version.

Thank you in advance.

2014-11-28 07:56:20 -0600 received badge  Good Question (source)
2014-11-25 21:42:45 -0600 marked best answer Using 2 Webcams Simultaneously

Can someone tell me if it is possible to capture from 2 webcams simultaneously at a resolution of 640x480? When capturing at a resolution of 320x240 or less, everything is fine, however when capturing at a resolution greater than that then I get the following the error:

libv4l2: error turning on stream: No space left on device

VIDIOC_STREAMON: No space left on device

Does anyone know how to solve this problem?

2014-07-31 02:49:21 -0600 marked best answer Extract a RotatedRect area

Can someone explain to me how you would extract a RotatedRect to a submatrix image. Basically, using something like cvSetImageROI to extract the inverted rectangular area from the image?

The Mat::operator()(const Rect& roi) only takes in a Rectangle not a RotatedRect.

rotated rect region

2014-04-27 16:40:59 -0600 received badge  Popular Question (source)
2014-04-14 21:07:23 -0600 received badge  Notable Question (source)
2014-03-28 07:30:33 -0600 received badge  Nice Question (source)
2014-03-07 06:41:29 -0600 received badge  Famous Question (source)
2014-03-02 10:36:37 -0600 received badge  Nice Answer (source)