0

WHat I am trying to do is to take 2 2 images from then stitch them together in a loop. This is the code i am trying to use:

for i in range(1,3):
    imageA = cv2.imread('frame%d.jpg'%i);i=i+1;print imageA.shape;
    imageB = cv2.imread('frame%d.jpg'%i);i=i+1;print imageB.shape;
    result,vis = stitcher.stitch([imageA, imageB], showMatches=True)
    cv2.imwrite('Stitch%d.jpg'%n,result); n=n+1;

But it is giving an error:

Traceback (most recent call last):
  File "test1.py", line 123, in <module>
    imageA = cv2.imread('frame%d.jpg'%i);i=i+1;print imageA.shape;
AttributeError: 'NoneType' object has no attribute 'shape'

Now when i remove the for loop and only execute the statements which were in the loop, it runs perfectly fine.

What could be the problem?

Mobi Zaman
  • 605
  • 1
  • 6
  • 19
  • 1
    Mind that **after the loop**, the `i` always picks the next in the `range(..)` so updating in the loop has no effect on the next iteration. – Willem Van Onsem Apr 05 '17 at 12:28
  • oh of course! I made such a silly mistake. Thanks a lot for your help! – Mobi Zaman Apr 05 '17 at 12:30
  • 1
    shouldn't affect your bug though. The reason is probably that your imread path is wrong. Try an absolute path, unless your frame%d.jpg is saved in the same folder your .py is saved in. – Soltius Apr 05 '17 at 12:47

0 Answers0