-
Notifications
You must be signed in to change notification settings - Fork 22
one openCV and 4 normal questions #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SarthakGupta0007
wants to merge
4
commits into
shivah12:main
Choose a base branch
from
SarthakGupta0007:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| str1 = input("Enter a word ") | ||
| str2 = input("Enter another word ") | ||
|
|
||
| str1 = sorted(str1) | ||
| str2 = sorted(str2) | ||
|
|
||
| if(str1 == str2): | ||
| print("The given words are anagram") | ||
| else: | ||
| print("The given words are not anagram") |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import numpy as np | ||
|
|
||
| r = int (input("Enter the rows of array")) | ||
| c = int (input("Enter the columns of array")) | ||
| a = np.zeros((r,c),dtype = 'int') | ||
|
|
||
| aT = np.zeros((c,r),dtype = 'int') | ||
|
|
||
| for i in range(r): | ||
| for j in range(c): | ||
| a[i][j] = int (input(f"Enter the element for row {r} and column {c} = ")) | ||
|
|
||
| for i in range(r): | ||
| for j in range(c): | ||
| aT[j][i] = a[i][j] | ||
|
|
||
|
|
||
| print(aT) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| st = input("Enter input ") | ||
| st = "".join(sorted(st)) | ||
| l = len(st) | ||
| i = 0 | ||
| count = 0 | ||
|
|
||
| while i < l: | ||
| c = st[i] | ||
| if(c == 32): | ||
| i+=1 | ||
| continue | ||
| count = 1 | ||
| while i+1 < l and st[i+1] == c: | ||
| count += 1 | ||
| i+=1 | ||
| print(f"{c} ==> {count}") | ||
| i+=1 | ||
|
|
||
|
|
||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import numpy as np | ||
|
|
||
| a = input("Enter number") | ||
| l = len(a) | ||
| a = np.array(list(a),dtype = 'int32') | ||
|
|
||
| i = l-1 | ||
|
|
||
| if(a[i]+1 == 10): | ||
| while(i>=0): | ||
| if(a[i]+1 >= 10): | ||
| a[i] = 0 | ||
| a[i-1] += 1 | ||
| i-=1 | ||
| else: | ||
| a[i] += 1 | ||
| i -= 1 | ||
|
|
||
| print(a) | ||
|
|
||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
|
|
||
| import cv2 | ||
| import numpy as np | ||
|
|
||
| # Open the webcam | ||
| cap = cv2.VideoCapture(0) | ||
|
|
||
| while True: | ||
| ret, frame = cap.read() | ||
| gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | ||
| hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) | ||
|
|
||
| lower_black = np.array([0, 0, 0]) | ||
| upper_black = np.array([180, 255, 30]) | ||
|
|
||
| lower_white = np.array([0, 0, 200]) | ||
| upper_white = np.array([180, 30, 255]) | ||
|
|
||
| mask_black = cv2.inRange(hsv, lower_black, upper_black) | ||
| mask_white = cv2.inRange(hsv, lower_white, upper_white) | ||
|
|
||
| contours_black, _ = cv2.findContours(mask_black, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) | ||
|
|
||
| for cnt in contours_black: | ||
| x, y, w, h = cv2.boundingRect(cnt) | ||
| cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) | ||
|
|
||
| contours_white, _ = cv2.findContours(mask_white, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) | ||
|
|
||
| for cnt in contours_white: | ||
| x, y, w, h = cv2.boundingRect(cnt) | ||
| cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) | ||
| cv2.imshow('Webcam', frame) | ||
|
|
||
| if cv2.waitKey(1) & 0xFF == ord('q'): | ||
| break | ||
|
|
||
| cap.release() | ||
| cv2.destroyAllWindows() |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import cv2 as cv | ||
| import numpy as np | ||
|
|
||
| cap = cv.VideoCapture(0); | ||
|
|
||
| while True: | ||
| _,frame = cap.read(); | ||
| frame = cv.cvtColor(frame,cv.COLOR_BGR2GRAY) | ||
| frame = cv.Canny(frame,80,150) | ||
| cv.imshow('WebCam',frame) | ||
| if cv.waitKey(1) & 0xFF == ord('q'): | ||
| break | ||
|
|
||
| cap.release() | ||
| cv.destroyAllWindows() |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import numpy as np | ||
| ##You can make the changes in test1.txt to check the working of this program | ||
|
|
||
| def primeChecker(num): | ||
| if num <= 1: | ||
| return False | ||
|
|
||
| for i in range(2,int(num / 2)+1): | ||
| if num % i == 0: | ||
| return False | ||
| return True | ||
|
|
||
| f = open('test1.txt', 'r') # Passing Reference of file in read mode | ||
| N = int(f.readline()) # Reading the first line | ||
| arr = np.array(f.readline().split(),dtype = 'int32') # Reading the second line and converting it to a numpy array | ||
| print(N) | ||
| print(arr) | ||
| f.close() | ||
| minP = 2147483647 #Assigning the minP variable with max int value will facilitate store the min value | ||
| maxP = -2147483648 # Vice versa | ||
|
|
||
| for n in arr: | ||
| if primeChecker(n) : | ||
| if n > maxP : | ||
| maxP = n | ||
| if n < minP : | ||
| minP = n | ||
| print(minP) | ||
| print(maxP) | ||
| print(f"The abs diff of max and min prime number in this array is = {abs(maxP - minP)}") | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| def primeChecker(num): | ||
| if num <= 1: | ||
| return False | ||
| if num == 2: | ||
| return True | ||
| if num % 2 == 0: | ||
| return False | ||
| for i in range(3, int(num / 2) +1): | ||
| if num % i == 0: | ||
| return False | ||
| return True | ||
|
|
||
| f = open('Q7text.txt','r') | ||
| N = int (f.readline()) | ||
| r = [0]*N# costs | ||
| rp = [0]*N #roys pay | ||
| for i in range(N): | ||
| r[i] = int (f.readline()) | ||
| f.close() | ||
|
|
||
| for i in range(N): | ||
| for j in range(r[i]): | ||
| if primeChecker(j) : | ||
| if r[i] % j == 0: | ||
| rp[i] = r[i]-j | ||
| break | ||
| print(rp) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| 2 | ||
| 5 | ||
| 10 |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| str = input("Enter a string : ") | ||
| str = list(str) | ||
| ele_dict = {} | ||
| str.sort() | ||
| count = 0 | ||
| for i in str: | ||
| if i in ele_dict: | ||
| ele_dict[i]+=1 | ||
| else: | ||
| ele_dict[i] = 1 | ||
| print(ele_dict) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 5 | ||
| 1 2 3 4 5 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct