Skip to content

Commit cc75897

Browse files
authored
Merge branch 'avinashkranjan:master' into master
2 parents c6fe868 + 39e6c60 commit cc75897

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

Live Currency Converter GUI/app.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,38 @@
55
BASE_URL = "http://api.exchangeratesapi.io/v1/latest"
66
API_KEY = "Your API Key"
77

8+
89
class CurrencyConverterApp:
910
def __init__(self, root):
1011
self.root = root
1112
self.root.title("Currency Converter")
1213
self.root.configure(bg="black")
1314

14-
15-
self.amount_label = tk.Label(root, text="Amount:", fg="white", bg="black")
15+
self.amount_label = tk.Label(
16+
root, text="Amount:", fg="white", bg="black")
1617
self.amount_label.pack()
1718

18-
19-
2019
self.amount_entry = tk.Entry(root)
2120
self.amount_entry.pack()
2221

23-
24-
25-
self.from_label = tk.Label(root, text="From Currency:", fg="white", bg="black")
22+
self.from_label = tk.Label(
23+
root, text="From Currency:", fg="white", bg="black")
2624
self.from_label.pack()
2725

2826
self.from_currency_entry = tk.Entry(root)
2927
self.from_currency_entry.pack()
3028

31-
32-
33-
34-
self.to_label = tk.Label(root, text="To Currency:", fg="white", bg="black")
29+
self.to_label = tk.Label(
30+
root, text="To Currency:", fg="white", bg="black")
3531
self.to_label.pack()
3632

3733
self.to_currency_entry = tk.Entry(root)
3834
self.to_currency_entry.pack()
3935

40-
41-
42-
self.convert_button = tk.Button(root, text="Convert", command=self.convert_currency)
36+
self.convert_button = tk.Button(
37+
root, text="Convert", command=self.convert_currency)
4338
self.convert_button.pack()
4439

45-
46-
4740
def get_rates(self):
4841
payload = {"access_key": API_KEY}
4942

@@ -61,8 +54,6 @@ def get_currency(self, currency, rates):
6154
else:
6255
raise ValueError(f"{currency} is not a valid currency")
6356

64-
65-
6657
def convert_currency(self):
6758
amount = float(self.amount_entry.get())
6859

@@ -75,10 +66,11 @@ def convert_currency(self):
7566
from_rate = self.get_currency(from_currency, rates)
7667
to_rate = self.get_currency(to_currency, rates)
7768

78-
7969
conversion = round((to_rate / from_rate) * amount, 2)
8070

81-
messagebox.showinfo("Conversion Result", f"{amount:.2f} ({from_currency}) is {conversion:.2f} ({to_currency})")
71+
messagebox.showinfo(
72+
"Conversion Result", f"{amount:.2f} ({from_currency}) is {conversion:.2f} ({to_currency})")
73+
8274

8375
def main():
8476
app = tk.Tk()
@@ -87,8 +79,8 @@ def main():
8779

8880
currency_converter = CurrencyConverterApp(app)
8981

90-
9182
app.mainloop()
9283

84+
9385
if __name__ == "__main__":
9486
main()

watermark on videos/app.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
11
import cv2
22
import numpy as np
33

4+
45
def add_watermark(input_video_path, output_video_path, watermark_path, position=(10, 10)):
56
video_capture = cv2.VideoCapture(input_video_path)
67
watermark = cv2.imread(watermark_path, cv2.IMREAD_UNCHANGED)
78
watermark_height, watermark_width, _ = watermark.shape
89
frame_width = int(video_capture.get(3))
910
frame_height = int(video_capture.get(4))
1011
fourcc = cv2.VideoWriter_fourcc(*'XVID')
11-
output_video = cv2.VideoWriter(output_video_path, fourcc, 30.0, (frame_width, frame_height))
12+
output_video = cv2.VideoWriter(
13+
output_video_path, fourcc, 30.0, (frame_width, frame_height))
1214

1315
while True:
1416
ret, frame = video_capture.read()
1517

1618
if not ret:
1719
break
1820

19-
resized_watermark = cv2.resize(watermark, (frame_width // 4, frame_height // 4))
20-
roi = frame[position[1]:position[1] + resized_watermark.shape[0], position[0]:position[0] + resized_watermark.shape[1]]
21+
resized_watermark = cv2.resize(
22+
watermark, (frame_width // 4, frame_height // 4))
23+
roi = frame[position[1]:position[1] + resized_watermark.shape[0],
24+
position[0]:position[0] + resized_watermark.shape[1]]
2125

2226
if watermark.shape[2] == 4:
2327
mask = resized_watermark[:, :, 3]
2428
mask_inv = cv2.bitwise_not(mask)
2529
img_bg = cv2.bitwise_and(roi, roi, mask=mask_inv)
26-
img_fg = cv2.bitwise_and(resized_watermark[:, :, :3], resized_watermark[:, :, :3], mask=mask)
30+
img_fg = cv2.bitwise_and(
31+
resized_watermark[:, :, :3], resized_watermark[:, :, :3], mask=mask)
2732
dst = cv2.add(img_bg, img_fg)
28-
frame[position[1]:position[1] + resized_watermark.shape[0], position[0]:position[0] + resized_watermark.shape[1]] = dst
33+
frame[position[1]:position[1] + resized_watermark.shape[0],
34+
position[0]:position[0] + resized_watermark.shape[1]] = dst
2935

3036
else:
31-
frame[position[1]:position[1] + resized_watermark.shape[0], position[0]:position[0] + resized_watermark.shape[1]] = resized_watermark[:, :, :3]
37+
frame[position[1]:position[1] + resized_watermark.shape[0], position[0] :position[0] + resized_watermark.shape[1]] = resized_watermark[:, :, :3]
3238

3339
output_video.write(frame)
3440

@@ -38,4 +44,5 @@ def add_watermark(input_video_path, output_video_path, watermark_path, position=
3844
print("Watermark added successfully!")
3945

4046

41-
add_watermark('input_video.mp4', 'output_video_with_watermark.mp4', 'watermark.png')
47+
add_watermark('input_video.mp4',
48+
'output_video_with_watermark.mp4', 'watermark.png')

0 commit comments

Comments
 (0)