0

I was reading OpenCV library functions that I encountered to this function:

void cv::logPolar(
cv::InputArray src,
cv::OutputArray dst,
cv::Point2f center,
double m,
int flags = cv::INTER_LINEAR | cv::WARP_FILL_OUTLIERS
);

In last argument (flag) it takes two inputs at the same time separated by | . How is it possible and How does it work?

Hasani
  • 3,543
  • 14
  • 65
  • 125
  • 3
    lookup [Bitwise-OR](http://en.cppreference.com/w/cpp/language/operator_arithmetic#Bitwise_logic_operators) – Vishaal Shankar Jun 11 '18 at 08:35
  • 3
    the `=` is for default argument, `|` is just the bitwise operator, `cv::INTER_LINEAR` and `cv::WARP_FILL_OUTLIERS` are probably just flags that are combined through the `|` – Tyker Jun 11 '18 at 08:36
  • I don't think it's a duplicate. The OP of *this* question needs to understand *both* the problem that the OP of the suggested duplicate had, *and* default arguments. – Martin Bonner supports Monica Jun 11 '18 at 08:46
  • @MartinBonner In its current state, this question does not mention any issue with default arguments, it just happens to be part of the example. – Holt Jun 11 '18 at 08:48
  • @Hasani If the duplicate does not answer your question, feel free to comment why, and maybe edit your question accordingly. – Holt Jun 11 '18 at 08:53
  • Thank you guys, I got my answer. – Hasani Jun 11 '18 at 20:05

1 Answers1

1

The | is a bitwise OR operation performed between two flags cv::INTER_LINEAR and cv::WARP_FILL_OUTLIERS.

According to the OpenCV documentation, the value of cv::INTER_LINEAR is 1(binary : 0001 ) and that of cv::WAR_FILL_OUTLIERS is 8(binary : 1000 ).

Therefore, the bitwise OR operation on them would provide a result of 1001 or 9 in decimal.

This is provided as a default argument to the function parameter flags.

Vishaal Shankar
  • 1,648
  • 14
  • 26