Skip to content
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

color tracker #84

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions projects/Get_Html/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Get The HTML Code

![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)

#100daysofcode This simple programe written in python with beautifulsoup module and the requests library.<br>
This programe allows you to get the html code from any website.<br>
Click <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/"> here </a> to read more about beautifulsoup.<br>
Click <a href="https://requests.readthedocs.io/en/master/"> here </a> to read more about requests.

## Features :dart:
* [x] Free & Open Source
* [x] Very Easy to use

## Screenshot
Home | Paste The Link
:---------------------: | :-----------------:
![screenshoot](screenshots/gh1.png) | ![screenshoot](screenshots/gh2.png)
Get The Code | Simple Question
![screenshoot](screenshots/gh3.png) | ![screenshoot](screenshots/gh4.png)

## Requirements
* python
* beautifulsoup
* requests

## How To Use It
1. Download Python from this link: https://www.python.org/downloads/
2. Install the packeges, write in your command (cmd):
```bash
pip install beautifulsoup4
pip install requests
```
3. Install this repository, click <a href="https://github.com/mohamedyanis/covid19-tracker2/archive/master.zip"> here </a> to install it.
4. Extract the folder
5. Run the ```gethtml.py``` file

## Contributing 💡
If you want to contribute to this project and make it better with new ideas, your pull request is very welcomed.<br>
If you find any issue just put it in the repository issue section, thank!<br><br>
.سبحَانَكَ اللَّهُمَّ وَبِحَمْدِكَ، أَشْهَدُ أَنْ لا إِلهَ إِلأَ انْتَ أَسْتَغْفِرُكَ وَأَتْوبُ إِلَيْ
14 changes: 14 additions & 0 deletions projects/Get_Html/gethtml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from bs4 import BeautifulSoup
import requests
c = True
while c:
url =input('Enter The Url Here: ')
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.prettify())
cc = input('''

Do You Want To Scrap Another WebSite (Y/N): ''')
if cc.lower() == 'n':
print('Thanks..!')
c = False
Binary file added projects/Get_Html/screenshots/gh1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/Get_Html/screenshots/gh2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/Get_Html/screenshots/gh3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/Get_Html/screenshots/gh4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions your_projects/color_tracking/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="">
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="28"/>
<application android:icon="@mipmap/ic_launcher" android:label="">
<activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
1 change: 1 addition & 0 deletions your_projects/color_tracking/code/sketch.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
component=app
74 changes: 74 additions & 0 deletions your_projects/color_tracking/color_tracking.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import processing.video.*;

// Variable for capture device
Capture video;

// A variable for the color we are searching for.
color trackColor;

void setup() {
size(1500,1000); //size(640, 480);
video = new Capture(this, 640, 480); //width , height);,
video.start();
// Start off tracking for red
trackColor = color(255, 0, 0);
}

void captureEvent(Capture video) {
// Read image from the camera
video.read();
}

void draw() {
video.loadPixels();
image(video, 0, 0);

// Before we begin searching, the "world record" for closest color is set to a high number that is easy for the first pixel to beat.
float worldRecord = 500;

// XY coordinate of closest color
int closestX = 0;
int closestY = 0;

// Begin loop to walk through every pixel
for (int x = 0; x < video.width; x ++ ) {
for (int y = 0; y < video.height; y ++ ) {
int loc = x + y*video.width;
// What is current color
color currentColor = video.pixels[loc];
float r1 = red(currentColor);
float g1 = green(currentColor);
float b1 = blue(currentColor);
float r2 = red(trackColor);
float g2 = green(trackColor);
float b2 = blue(trackColor);

// Using euclidean distance to compare colors
float d = dist(r1, g1, b1, r2, g2, b2); // We are using the dist( ) function to compare the current color with the color we are tracking.

// If current color is more similar to tracked color than
// closest color, save current location and current difference
if (d < worldRecord) {
worldRecord = d;
closestX = x;
closestY = y;
}
}
}

// We only consider the color found if its color distance is less than 10.
// This threshold of 10 is arbitrary and you can adjust this number depending on how accurate you require the tracking to be.
if (worldRecord < 10) {
// Draw a circle at the tracked pixel
fill(trackColor);
strokeWeight(4.0);
stroke(0);
ellipse(closestX, closestY, 16, 16);
}
}

void mousePressed() {
// Save color where the mouse is clicked in trackColor variable
int loc = mouseX + mouseY*video.width;
trackColor = video.pixels[loc];
}