1

I am doing a haar cascade to detect license plate images. Once such image is detected, i crop and save it to disk. This image will then be passed on (loaded) further down for processing & segmentation. It's a 'live feed' so it will continually capture it. How do i have it pass on to the next code once the image is saved?

this is the current code

for x,y,w,h in detected:
        
        temp = img.draw_rectangle(x,y,w,h, thickness=5)
        extracted = temp.crop(roi=(x,y,w,h),copy=False) 
        extracted.save('extracted_img.png')

in the same vein, further down, i segment the image and save 7 characters (my license plate has 7 characters). How do i go about exiting it once 7 images are saved?

This is partial code that's within a for loop that iterates through the list of detected bounding boxes

for i in range(len(detected_list)):
  x = ...
  y = ...
  width = ...
  height = ...

  if height > width: 
            cropped.save('trial-%d'%i,roi=(x,y,width,height))

i managed to save the images but since it's live it'll keep overwriting the files. Similar to the above query, once i have 7 images saved i want to break out of this and continue with the rest of the code (which is passing the images into a character recognition model)

Parlielion
  • 23
  • 2
  • You just `return` the first valid image, that will brake out of all the loops of that function – SrPanda Jun 16 '22 at 04:33
  • @SrPanda thanks will try that out. how about the 2nd bit? do i return all 7 images that were saved to the drive or somehow count them? – Parlielion Jun 16 '22 at 04:51
  • I amused that bought loops are in the same function , but if you have enough memory to just have all in memory just return it as a tuple and im not sure what you mena buy count but if it is just recognizing individual letter you could return the list of each match – SrPanda Jun 16 '22 at 05:13
  • oh they are not in the same function since the flow is roughly like detect image & crop & save it (here to exit the loop once it's saved) --> pre-processing step --> extract segmented characters (2nd for loop here that continually takes and saves the characters & where the 2nd loop to be exited once 7 images are saved since the license has 7 characters) – Parlielion Jun 16 '22 at 05:15
  • Then use the típica buffer swap, bought functions have a image and once bought of them are done they swap and repeat, in python is more like a shared list where bought functions can access the content and could use an atlas map for the images as they should be small – SrPanda Jun 16 '22 at 05:27

0 Answers0