Ask Your Question
1

Problem when using dot product with Xcode

asked 2018-07-26 05:41:03 -0600

Khoa Le gravatar image

updated 2018-07-26 17:06:06 -0600

Dear friends,

Please give me some idea how to solve this problem. I wrote a very simple program that executes dot product between two points, A = (1,2), B = (2,5). However, I could not implement it because of the error No viable overload '=' (compiler explains: "candidate function not viable: no known function from 'int' to 'const cv::Point_<int>' for 1st argument"). I am using Open CV 3.4.2 and Xcode 9.2. Below is my implementation.

#include<iostream>
#include<opencv2/opencv.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/core/types.hpp>
using namespace cv;
using namespace std;
int main()
{
Point A(1,2);
Point B(2,5);
Point C = B.dot(A); 
return 0;
}
edit retag flag offensive close merge delete

Comments

i removed your screenshot, those are useless here.

please EDIT your QUESTION, and add a TEXT version of your code and the resulting errors, thank you.

berak gravatar imageberak ( 2018-07-26 09:39:43 -0600 )edit

please check wikipedia for dot product : result is a scalar

LBerger gravatar imageLBerger ( 2018-07-27 00:05:46 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-07-28 07:02:27 -0600

Khoa Le gravatar image

I changed Point C = B.dot(A); to int c = B.dot(A); and the problem was solved. However, the thing is the old implementation can work on Visual Studio 2017. Don't know why.

edit flag offensive delete link more

Comments

Yes that's weird! threre is an implicit conversion int to Point (or vec2i) in VS2017 @berak

LBerger gravatar imageLBerger ( 2018-07-28 08:58:02 -0600 )edit

no, there is no such thing. (i don't have VS)

(and i'd simply prefer, not to believe an already confused person here ;)

berak gravatar imageberak ( 2018-07-28 10:25:57 -0600 )edit
1

"not to believe an already confused person here " ??? In vs 2017 I tried and it works Point C = B.dot(A); c.x is scalar product

LBerger gravatar imageLBerger ( 2018-07-28 11:18:23 -0600 )edit

ok, i'll have to believe it, then ;)

all i can see from here: it does not have an "explicit" constructor

berak gravatar imageberak ( 2018-07-28 12:37:20 -0600 )edit

I tried Point C= 28; strack trace is :

TD1.exe!cv::Matx<int,2,1>::Matx<int,2,1>(int v0) Line 541   C++
TD1.exe!cv::Vec<int,2>::Vec<int,2>(int v0) Line 969 C++
TD1.exe!main() Line 167 C++

28 is convert in Mat2x and in Vec2i then Vec2i is convert in Point :

TD1.exe!cv::Point_<int>::Point_<int>(const cv::Vec<int,2> & v) Line 1174    C++
TD1.exe!main() Line 168 C++
LBerger gravatar imageLBerger ( 2018-07-28 14:01:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-07-26 05:41:03 -0600

Seen: 201 times

Last updated: Jul 28 '18