cvtColor TypeError:
TypeError: only length-1 arrays can be converted to Python scalars
These are the images:
bash-4.1$ rdjpgcom -v Bayer.jpg
JPEG image is 3072w * 2600h, 1 color components, 8 bits per sample
JPEG process: Baseline
bash-4.1$ rdjpgcom -v out.jpg
JPEG image is 3072w * 2600h, 3 color components, 8 bits per sample
JPEG process: Baseline
This is my problem:
bash-4.1$ python3 (same result with python2.7.9, Windows or Linux)
Python 3.4.3 (default, Mar 2 2015, 06:20:41)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2; # (same result with 2.4.10 or 3.0.0)
>>> image = cv2.imread('Bayer.jpg', 1);
>>> cimage = cv2.imread('out.jpg', 0);
>>> cv2.cvtColor(image, cimage, 49); #(Same result with other conversion types also)
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: only length-1 arrays can be converted to Python scalars
?
cv2.cvtColor(image, cimage, 49);
can't work, do you mean:out = cv2.cvtColor(img, cv2.BGR2GRAY')
(or other conversion type) , then you can save it viacv2.imwrite('out.png', out)
or have a look at it withcv2.imshow('out', out)
(+cv2.waitKey()
).BGR2GRAY works with my images, and I can imshow, and imwrite the output. However using demosaicing (CV_BayerGR2BGR=49) the out = cv2.cvtColor(img,49,3) syntax does not work because the output does not pass the test for 3 or 4 channels: cv2.error: demosaicing.cpp:1647: error: (-215) scn == 1 && (dcn == 3 || dcn == 4) in function demosaicing Using the alternate form: cv2.cvtColor(img, out, 49) when out is defined as 3 band, passes the test but fails with the TypeError: TypeError: only length-1 arrays can be converted to Python scalars
Please look at the accepted answer here: http://answers.opencv.org/question/19... which deals with a similar problem.