কম্পিউটার

OpenCV ব্যবহার করে একটি ছবিতে একটি লাইন আঁকুন


এই প্রোগ্রামে, আমরা OpenCV ফাংশন লাইন().

ব্যবহার করে একটি চিত্রের উপর একটি সরল রেখা আঁকব

মূল ছবি

OpenCV ব্যবহার করে একটি ছবিতে একটি লাইন আঁকুন

অ্যালগরিদম

Step 1: Import cv2.
Step 2: Read the image using imread().
Step 3: Get the dimensions of the image using the image.shape method.
Step 4: Define starting point of the line.
Step 5: Define the end point of the line.
Step 6: Define the thickness of the line.
Step 7: Draw the line using the cv2.line() function and pass Step 3 to Step 4 as parameters.

উদাহরণ কোড

import cv2

image = cv2.imread('testimage.jpg')
height, width, channels = image.shape
startpoint = (0, 0)
endpoint = (height, width)
thickness = 9
color = (255, 0, 0)
image = cv2.line(image, startpoint, endpoint, color, thickness)
cv2.imshow('Line', image)

আউটপুট

OpenCV ব্যবহার করে একটি ছবিতে একটি লাইন আঁকুন

ব্যাখ্যা

আপনি দেখতে পাচ্ছেন, ছবিতে একটি নীল রেখা আঁকা হয়েছে৷


  1. OpenCV ব্যবহার করে ছবি পড়া এবং প্রদর্শন করা

  2. OpenCV ব্যবহার করে চিত্রের পাইথন গ্রেস্কেলিং

  3. পাইথনে OpenCV ব্যবহার করে একটি ছবিতে চেনাশোনা খুঁজুন

  4. পাইথনে OpenCV ব্যবহার করে কনট্যুর খুঁজুন এবং আঁকুন