Multiple Videocapture object for a new written single video

asked 2018-09-16 03:38:17 -0500

reso737 gravatar image


How can I write a multiple VideoCapture object as an separating variable like VideoCapture() named cap1 for Video A, cap2 for VideoB and so on.

def make4side(image, scale=0.5):    
    # image = cv2.imread(image)
    h = int((image.shape[0])) #height
    w = int((image.shape[1])) #width
    image = cv2.resize(image, (w,h ), interpolation = cv2.INTER_CUBIC) #shrink image to half

    output = np.zeros((w+h+h , w + h + h, 3), dtype="uint8")

# top 
    output[0:h, h:h+w] = image 
# left >> rotate 90
    output[h:h+w, 0:h] = np.rot90(image,1) 
# right >> rotate 270
    output[h:h+w, h+w:h+w+h] = np.rot90(image,3)  
# bottom >> rotate 180
    output[h+w:h+w+h, h:h+w] = np.rot90(image,2) 

    return output

The code above is the function which I am going to apply during the time I read the VideoCapture. For this, its only read just one single file which is image. My question is how can I write a Videocapture object to read multiple videos and named it separately like cap1, cap2 so that I can placed for example cap1 for a top side, cap2 for left side, cap3 for right side and cap4 for bottom side (by changing the image in each of the side to be exact video that I want to place)

Thank you

edit retag flag offensive close merge delete


@reso737 From your question, what I am understood is that, you have 4cameras and you have to take video from 4 cameras. I am right? You want to capture feed parallelly or serially?

ak1 gravatar imageak1 ( 2018-09-17 00:32:26 -0500 )edit

It's right that I have 4 cameras and have to take 4 videos. But let assume that I already have 4 video files. I want the processing time to be less so should I capture it by parallel or serial?

reso737 gravatar imagereso737 ( 2018-09-17 01:04:45 -0500 )edit

capture it parallel using multithreading.

ak1 gravatar imageak1 ( 2018-09-17 01:17:39 -0500 )edit

@reso737 follow below blog. Link: Here you will get code for multi-thread camera capture. I think this will solves your problem.

ak1 gravatar imageak1 ( 2018-09-17 01:22:53 -0500 )edit

thank you :) will look in it

reso737 gravatar imagereso737 ( 2018-09-17 02:18:26 -0500 )edit

Sorry, I tried to read the blog that you gave but I don't seem to understand about the code(which is C)and explaination of it. @ak1

reso737 gravatar imagereso737 ( 2018-09-17 04:52:08 -0500 )edit

@reso737 You know multi-threading ? Specify which line you are not understanding. Try to check online tutorial on multi-threading. It is C++ not C.

ak1 gravatar imageak1 ( 2018-09-17 06:18:44 -0500 )edit

I knew the simple idea of multi-threading. Sorry but I don't get the idea of the link on how to apply to mine, I never write C++ before which made me struggle

reso737 gravatar imagereso737 ( 2018-09-17 09:10:28 -0500 )edit

@reso737 you want to me to edit his code for you ? I will ask you to again go through the explanation of his blog. This is exactly doing the same, which you are trying to do.

ak1 gravatar imageak1 ( 2018-09-18 00:35:13 -0500 )edit

Thank you for helping, I did it without using a multi-threading >> instead use only a videocapture() objects for each of the input video @ak1

reso737 gravatar imagereso737 ( 2018-09-19 01:13:20 -0500 )edit