Posts

Showing posts from September, 2024

OpenCV Drawing Fucntions cv.line(), cv.circle() , cv.rectangle(), cv.ellipse(), cv.putText()

cv.line() This is used to draw a line on passed MAT(window part) actually it changes the color of the window pixel from given point to ending given points with adjesting the color and thickness by passing as argument along with MAT and other import attributes    cv.circle() Similarly it is also USed to create the shape which Circle we passes here the radius and the middle point to the circle similarly for other functions,  can take information about the argument passed in these functions from official website of the OpenCV but some common arguments are,MAT,  color, thickness, radius, size, initial point, ending point  cv.ellipse()  Used to create the ellipse with different different attributes  To draw the ellipse, we need to pass several arguments. One argument is the center location (x,y). Next argument is axes lengths (major axis length, minor axis length). angle is the angle of rotation of ellipse in anti-clockwise direction. startAngle and endAngle denotes the starting and ending

OpenCV : VideoWritter()

This is the Function used to write the video in permanent memory  Arguments, 1.  FileName with Extension  2. fourCC code from VideoWriter_fourcc() function which takes fourcc codes like XVID,DVIX etc 3. the FPS or frame per second 4. tuple of the Dimension recommended to use predefined dimensions wisely otherwise u can face errors 5. Color which takes an boolean value and decides the color of video if 1 then coloured other wise grayscale code : import cv2 as cv cap   = cv. VideoCapture ( 0 ) fourcc = cv. VideoWriter_fourcc ( * ' XVID ') output   = cv. VideoWriter (" ./output/myvideo.avi ", fourcc , 20.0 ,( 640 , 480 )) while cap. isOpened ():     ret, frame = cap. read ()     print ( frame )     if not ret:         break     # frame  = cv.flip(frame,0)     cv. imshow (" Video Capturing ", frame )     output. write ( frame )     if cv. waitKey ( 20 ) & 0x FF == ord (' x '):         print (' Video saved Successfully in current Dire

OpenCV python : cv.VideoWriter_fourcc(*argu)

 Introduction This is the function to generate the fourcc code for video compression or video saving system it returns an integer value that will pass to VideoWritter function as an argument so it will  save the video according to the fourcc opted, code: fourcc = cv. VideoWriter_fourcc ( * ' XVID ') import cv2 as cv cap   = cv. VideoCapture ( 0 ) fourcc = cv. VideoWriter_fourcc ( * ' XVID ') output   = cv. VideoWriter (" ./output/myvideo.avi ", fourcc , 20.0 ,( 640 , 480 )) while cap. isOpened ():     ret, frame = cap. read ()     print ( frame )     if not ret:         break     # frame  = cv.flip(frame,0)     cv. imshow (" Video Capturing ", frame )     output. write ( frame )     if cv. waitKey ( 20 ) & 0x FF == ord (' x '):         print (' Video saved Successfully in current Directory ')         break #Now most important part releasing all the resourses to prevent the conflict between the resourses output. relea

Computer Vision - VideoCapture()

 Introduction and Use This is a function used to start capturing the video or starting the reading process or Simply opening the camera or start playing the video with imshow()  for accurate : This is used to load the video in Memory so we can read  and show the video frame by frame which is an another task  code: import cv2 as cv cap   = cv. VideoCapture ( 0 ) fourcc = cv. VideoWriter_fourcc ( * ' XVID ') output   = cv. VideoWriter (" ./output/myvideo.avi ", fourcc , 20.0 ,( 640 , 480 )) while cap. isOpened ():     ret, frame = cap. read ()     if not ret:         break     frame   = cv. flip ( frame , 0 )     cv. imshow (" Video Capturing ", frame )     output. write ( frame )     if cv. waitKey ( 20 ) & 0x FF == ord (' x '):         print (' Video saved Successfully in current Directory ')         break #Now most important part releasing all the resourses to prevent the conflict between the resourses output. release () ca

Pageviews