How should i use the calcHist method
How should i use the calcHist method? I tried the Described/suggested things to run this method but each step im getting error. Do you have some referance how can i do the color histogram.If possible need seperate histogram for each color i.e b r g.
does this help https://github.com/rainyl/opencv_dart/blob/0fee178780af25a2c8fcb91226c8ca8b6f88db98/test/imgproc/imgproc_test.dart#L57 ?
Yes , i was able to extract the pixel density thanks it was really helpfull @abdelaziz-mahdy . Can you please help me out on one more thing? Im trying to detect for example any object in shades of say red , im using method
cv.Mat hsv = cv.imdecode(bytes,cv.COLOR_BGR2HSV); cv.Mat mask1=cv.inRangebyScalar(mat, cv.Scalar(0, 100, 100), cv.Scalar(10, 255, 255)); // lower range cv.Mat mask2=cv.inRangebyScalar(mat, cv.Scalar(160, 100, 100), cv.Scalar(179, 255, 255)); // upper range
but im not sure in cv.Scalar are we putting rgb , bgr or hsv , because from the example videos of python the value which they used are not working , even when i tried the usinf rgb , brg or hsv im not getting the expected result. Can you please clarify this? Also if i have histogram data how can i deduce lower and upper limit of red or some method similar to cv.createTrackbar from python.
Sorry I don't have the knowledge in the first question to answer you
But for createTrackbar it exists on highgui module and it should be implemented but it's not there so @rainyl do you know why it's not implemented in the dart side?
Sorry for the late reply, I was on vacation recently.
@KartikGavhale As abdelaziz-mahdy suggested, you can always find an example in our tests at https://github.com/rainyl/opencv_dart/tree/main/test
And the code you attached above is incorrect
// Here, the flags of `imdecode` is same as `imread`, so you can't use the conversion flags like
// `cv.COLOR_BGR2HSV`, read more at https://docs.opencv.org/4.10.0/d4/da8/group__imgcodecs.html#gaad518fe65098fd32446bd5b9c4f8b531
cv.Mat hsv = cv.imdecode(bytes,cv.COLOR_BGR2HSV);
cv.Mat mask1=cv.inRangebyScalar(mat, cv.Scalar(0, 100, 100), cv.Scalar(10, 255, 255)); // lower range
cv.Mat mask2=cv.inRangebyScalar(mat, cv.Scalar(160, 100, 100), cv.Scalar(179, 255, 255)); // upper range
but im not sure in cv.Scalar are we putting rgb , bgr or hsv
AFAIK, the order of cv.Scalar is same as the Mat you are processing, i.e., if Mat is BGR, cv.Scalar should be constructed by BGR like final lb = cv.Scalar(B, G, R, X), (here X is not used, so it can be any values), more info here: https://docs.opencv.org/4.10.0/d2/de8/group__core__array.html#ga48af0ab51e36436c5d04340e036ce981
some method similar to cv.createTrackbar from python. But for createTrackbar it exists on highgui module and it should be implemented but it's not there so @rainyl do you know why it's not implemented in the dart side?
This project was started from gocv, so same as gocv, Window and Trackbar are implemented via Classes, find more details here: https://pub.dev/documentation/opencv_dart/latest/cv.highgui/Trackbar-class.html and https://github.com/rainyl/opencv_dart/blob/main/test/highgui_test.dart
Maybe we can implement these methods in the future: https://docs.opencv.org/4.10.0/d7/dfc/group__highgui.html#gaf78d2155d30b728fc413803745b67a9b
@rainyl Thanks you for the clarification and suggetions.
If you have no more questions, I am going to close this issue, feel free to reopen it if needed.