Created
January 10, 2019 23:02
-
-
Save andrisgauracs/b19d2916356ef45b89dc254677ef26b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Once the list is full with all the images we need, we can start to | |
| # combine it into the final output image | |
| if (framesTaken == framesSpecified): | |
| resultImgs = [] | |
| for i in framesTakenList: | |
| # here we just add a whitespace rectangle as a top margin | |
| resultImgs.append(cv2.imread(i)) | |
| im = np.zeros(( | |
| borderSize*2, | |
| cv2.imread(i).shape[1], | |
| 3), np.uint8) | |
| cv2.rectangle( | |
| im, | |
| (0, 0), | |
| (cv2.imread(i).shape[1], borderSize * 2), | |
| (255, 255, 255), -1) | |
| # here we just add a whitespace rectangle as a bottom margin | |
| resultImgs.append(im) | |
| # Now that we have the list of all the needed images, | |
| # we concatinate them vertically and form the final image | |
| final = np.concatenate(resultImgs, axis=0) | |
| # The final image still needs an outside border, so the last task | |
| # is to create this border line | |
| finalShape = final.shape | |
| w = finalShape[1] | |
| h = finalShape[0] | |
| base_size = h+borderSize, w+borderSize, 3 | |
| base = np.zeros(base_size, dtype=np.uint8) | |
| # We combine our main image with the border line | |
| cv2.rectangle( | |
| base, | |
| (0, 0), | |
| (w + borderSize, h + borderSize), | |
| (255, 255, 255), borderSize) | |
| base[ | |
| (borderSize/2):h+(borderSize/2), | |
| (borderSize/2):w+(borderSize/2) | |
| ] = final | |
| # The final output image is ready. | |
| # We now export it to the root directory | |
| cv2.imwrite("result_image.png", base) | |
| sys.exit(app.exec_()) | |
| # If the image capture process continues, we resume playing the video | |
| self.PlayPause() if wasPlaying else None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment