[SOLVED] How do I translate Decode(Packet) function in C++?

Issue

This Content is from Stack Overflow. Question asked by Alessio

I am learning depth ai and I found this example on their repo. https://github.com/luxonis/depthai-experiments/tree/master/gen2-road-segmentation

I am trying to convert this code to C++ to be consistent across a project I started in C++. How can I “translate” the following function?

Thanks

def decode(packet):
    data = np.squeeze(toTensorResult(packet)["L0317_ReWeight_SoftMax"])
    class_colors = [[0, 0, 0], [0, 255, 0], [255, 0, 0], [0, 0, 255]]
    class_colors = np.asarray(class_colors, dtype=np.uint8)
    indices = np.argmax(data, axis=0)
    output_colors = np.take(class_colors, indices, axis=0)
    return output_colors



Solution

#I think you are looking for the 
cv::argmax # function.

cv::argmax # returns the index of the maximum value in an array.
cv::argmax # is available in OpenCV 3.4.3 and later.


This Question was asked in StackOverflow by Alessio and Answered by James It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?