Open darkdragon-001 opened 7 years ago
@alalek Why is this invalid?
I want to create a cv::plot::Plot2d
via cv::plot::createPlot2d()
and my data is in a std::map
which is a list of (x,y) pairs. I think this should be supported since it is very similar to a vector<cv::Point>
which can implicitly be converted to InputArray<cv::Point>
which should definitely be supported in the OpenCV world! I mean, it is quite common to plot a list of points in a plot...
Because it was unclear how this issue is related to OpenCV.
BTW, InputArray will not support std::map
, so overloaded function which extracts points (into std::vector) should be implemented.
@alalek could you please add the label category:plot
?
Hi @darkdragon-001, most of OpenCV classes only accept very limited types of inputs, either Mat or std::vector in some cases. To keep the same criteria, I implemented Plot2d this way. You can easily change your input data to match those, by creating separate vectors.
BTW, Only "InputArray" parameter type is supported as wrapper for Python/Java bindings - std::map and other non-scalar types are not supported.
@alalek is correct, there are standards for the OpenCV classes due to this multi-language compatibility. I kept the same criteria when implementing Plot2d. By changing the input types to not match these standards, Plot2d could not be an OpenCV module.
I would also relocate suggestions like this to #961
I would like to construct a
cv::plot::Plot2d
based on a STLstd::map
which is basically astd::list
ofstd::pair<X,Y>
which is similar tocv::Point
. I guess supporting astd::list
/std::vector
/std::iterable
/cv::Mat
ofcv::Point
is crucial, since plotting points is what you normally do. Further, when you do plotting, you always need those pairs (btw: it implicitly ensures there is an equal number of x and y coordinates). Currently, you store both vectors separately - probably because you can easily handle the case when the user only supplies y coordinates.Should I write a conversion to two
std::vector
? Or would it be a better idea to rewrite internal storage?@nmoutinho Maybe you can have a look?
Edit: clarified the question.