I am learning opencv-python image processing so I wrote this small code but I am getting an error I don't...
up vote
-1
down vote
favorite
This is my code give below for addition of image but it is giving me error
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
flower = cv2.imread('fall-autumn-red-season.jpg')
img = cv2.addWeighted(coke,0.3,flower,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
and i am getting this error
File "D:/Python codes/image addition.py", line 6, in
img = cv2.addWeighted(coke,0.3,flower,0.7,0)
cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmodulescoresrcarithm.cpp:659: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'
what should i do to remove the error
python opencv3.0
add a comment |
up vote
-1
down vote
favorite
This is my code give below for addition of image but it is giving me error
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
flower = cv2.imread('fall-autumn-red-season.jpg')
img = cv2.addWeighted(coke,0.3,flower,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
and i am getting this error
File "D:/Python codes/image addition.py", line 6, in
img = cv2.addWeighted(coke,0.3,flower,0.7,0)
cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmodulescoresrcarithm.cpp:659: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'
what should i do to remove the error
python opencv3.0
From what I understood, you are trying to apply add to 2 pictures of different sizes. Try to resize one image to the size of the second or both to the same size before applying theaddWeighted()
– Osuman AAA
Nov 11 at 8:08
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
This is my code give below for addition of image but it is giving me error
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
flower = cv2.imread('fall-autumn-red-season.jpg')
img = cv2.addWeighted(coke,0.3,flower,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
and i am getting this error
File "D:/Python codes/image addition.py", line 6, in
img = cv2.addWeighted(coke,0.3,flower,0.7,0)
cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmodulescoresrcarithm.cpp:659: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'
what should i do to remove the error
python opencv3.0
This is my code give below for addition of image but it is giving me error
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
flower = cv2.imread('fall-autumn-red-season.jpg')
img = cv2.addWeighted(coke,0.3,flower,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
and i am getting this error
File "D:/Python codes/image addition.py", line 6, in
img = cv2.addWeighted(coke,0.3,flower,0.7,0)
cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmodulescoresrcarithm.cpp:659: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'
what should i do to remove the error
python opencv3.0
python opencv3.0
edited Nov 11 at 10:12
Duco
105
105
asked Nov 11 at 8:02
Shubhanker Tiwari
12
12
From what I understood, you are trying to apply add to 2 pictures of different sizes. Try to resize one image to the size of the second or both to the same size before applying theaddWeighted()
– Osuman AAA
Nov 11 at 8:08
add a comment |
From what I understood, you are trying to apply add to 2 pictures of different sizes. Try to resize one image to the size of the second or both to the same size before applying theaddWeighted()
– Osuman AAA
Nov 11 at 8:08
From what I understood, you are trying to apply add to 2 pictures of different sizes. Try to resize one image to the size of the second or both to the same size before applying the
addWeighted()
– Osuman AAA
Nov 11 at 8:08
From what I understood, you are trying to apply add to 2 pictures of different sizes. Try to resize one image to the size of the second or both to the same size before applying the
addWeighted()
– Osuman AAA
Nov 11 at 8:08
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I cannot test since I do not have the images you are using, but try this code and let me know if it works now. I explained the issue in my comment.
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
coke1 = cv2.resize(coke,(500, 500), interpolation = cv2.INTER_AREA)
flower = cv2.imread('fall-autumn-red-season.jpg')
flower1 = cv2.resize(flower,(500, 500), interpolation = cv2.INTER_AREA)
img = cv2.addWeighted(coke1,0.3,flower1,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Thanks sir it is working but you made a very small mistake by writing flower2 instead of flower1 but still i corrected it by my self thanks a lot once again
– Shubhanker Tiwari
Nov 12 at 11:31
You're right ! I corrected it now !!
– Osuman AAA
Nov 12 at 12:39
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I cannot test since I do not have the images you are using, but try this code and let me know if it works now. I explained the issue in my comment.
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
coke1 = cv2.resize(coke,(500, 500), interpolation = cv2.INTER_AREA)
flower = cv2.imread('fall-autumn-red-season.jpg')
flower1 = cv2.resize(flower,(500, 500), interpolation = cv2.INTER_AREA)
img = cv2.addWeighted(coke1,0.3,flower1,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Thanks sir it is working but you made a very small mistake by writing flower2 instead of flower1 but still i corrected it by my self thanks a lot once again
– Shubhanker Tiwari
Nov 12 at 11:31
You're right ! I corrected it now !!
– Osuman AAA
Nov 12 at 12:39
add a comment |
up vote
0
down vote
accepted
I cannot test since I do not have the images you are using, but try this code and let me know if it works now. I explained the issue in my comment.
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
coke1 = cv2.resize(coke,(500, 500), interpolation = cv2.INTER_AREA)
flower = cv2.imread('fall-autumn-red-season.jpg')
flower1 = cv2.resize(flower,(500, 500), interpolation = cv2.INTER_AREA)
img = cv2.addWeighted(coke1,0.3,flower1,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Thanks sir it is working but you made a very small mistake by writing flower2 instead of flower1 but still i corrected it by my self thanks a lot once again
– Shubhanker Tiwari
Nov 12 at 11:31
You're right ! I corrected it now !!
– Osuman AAA
Nov 12 at 12:39
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I cannot test since I do not have the images you are using, but try this code and let me know if it works now. I explained the issue in my comment.
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
coke1 = cv2.resize(coke,(500, 500), interpolation = cv2.INTER_AREA)
flower = cv2.imread('fall-autumn-red-season.jpg')
flower1 = cv2.resize(flower,(500, 500), interpolation = cv2.INTER_AREA)
img = cv2.addWeighted(coke1,0.3,flower1,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
I cannot test since I do not have the images you are using, but try this code and let me know if it works now. I explained the issue in my comment.
import numpy as np
import cv2
coke = cv2.imread('coca cola.png')
coke1 = cv2.resize(coke,(500, 500), interpolation = cv2.INTER_AREA)
flower = cv2.imread('fall-autumn-red-season.jpg')
flower1 = cv2.resize(flower,(500, 500), interpolation = cv2.INTER_AREA)
img = cv2.addWeighted(coke1,0.3,flower1,0.7,0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
edited Nov 12 at 12:38
answered Nov 11 at 8:16
Osuman AAA
411212
411212
Thanks sir it is working but you made a very small mistake by writing flower2 instead of flower1 but still i corrected it by my self thanks a lot once again
– Shubhanker Tiwari
Nov 12 at 11:31
You're right ! I corrected it now !!
– Osuman AAA
Nov 12 at 12:39
add a comment |
Thanks sir it is working but you made a very small mistake by writing flower2 instead of flower1 but still i corrected it by my self thanks a lot once again
– Shubhanker Tiwari
Nov 12 at 11:31
You're right ! I corrected it now !!
– Osuman AAA
Nov 12 at 12:39
Thanks sir it is working but you made a very small mistake by writing flower2 instead of flower1 but still i corrected it by my self thanks a lot once again
– Shubhanker Tiwari
Nov 12 at 11:31
Thanks sir it is working but you made a very small mistake by writing flower2 instead of flower1 but still i corrected it by my self thanks a lot once again
– Shubhanker Tiwari
Nov 12 at 11:31
You're right ! I corrected it now !!
– Osuman AAA
Nov 12 at 12:39
You're right ! I corrected it now !!
– Osuman AAA
Nov 12 at 12:39
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246865%2fi-am-learning-opencv-python-image-processing-so-i-wrote-this-small-code-but-i-am%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
From what I understood, you are trying to apply add to 2 pictures of different sizes. Try to resize one image to the size of the second or both to the same size before applying the
addWeighted()
– Osuman AAA
Nov 11 at 8:08