Categories
Mastering Development

Apache beam processing sequential elements

I have a stream of GPS coordinates from different devices. Those coordinates could arrive out of order but they all have an event time. I want to calculate the total distance from GPS coordinates. From Beam Programming Guide: The combining function should be commutative and associative, as the function is not necessarily invoked exactly once […]

Categories
Mastering Development

Remove extra space before word ends

I need some help removing the extra place before a word/string ends. Does anyone have any ideas? input: hello output I get: ‘ …. . .-.. .-.. — ‘ expected output: ‘ …. . .-.. .-.. — ‘ MORSE_CODES={‘A’:’.-‘,’B’:’-…’,’C’:’-.-.’, ‘D’:’-..’,’E’:’.’,’F’:’..-.’,’G’:’–.’, ‘H’:’….’,’I’:’..’,’J’:’.—‘,’K’:’-.-‘, ‘L’:’.-..’,’M’:’–‘,’N’:’-.’,’O’:’—‘, ‘P’:’.–.’,’Q’:’–.-‘,’R’:’.-.’, ‘S’:’…’,’T’:’-‘,’U’:’..-‘,’V’:’…-‘, ‘W’:’.–‘,’X’:’-..-‘,’Y’:’-.–‘,’Z’:’–..’} def encode_Morse(my_msg): my_msg=my_msg.upper() my_msg_Morse=" " for letter in my_msg: if […]

Categories
Mastering Development

Make eye tracker that only scans the upper 1/2 of my face

My original idea can be seen in the code below but it’s still detecting eyes on the lower half of my face. The goal is to make it only scan the upper half of my face, therefore weeding out incorrect matches. import cv2 face_cascade = cv2.CascadeClassifier(‘haarcascade_frontalface_default.xml’) eye_cascade = cv2.CascadeClassifier(‘haarcascade_eye.xml’) cap = cv2.VideoCapture(0) # sets up […]

Categories
Mastering Development

why am I getting the key error in python?

I have an iris dataset which I want to load onto python and make some graphs with it Here is my error message Here is what it says KeyError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3077 try: -> 3078 return self._engine.get_loc(key) 3079 except KeyError: pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() […]

Categories
Mastering Development

An error shown while doin face detection in OpenCV 3.7.6

This is my code. import cv2 face_cascade = cv2.CascadeClassifier("Resources/haarcascade_frontalface_default.xml") img = cv2.imread("Resources/skirt.PNG") gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray_img,scaleFactor = 1.1,minNeighbors=4) for (x,y,w,h) in faces: img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) cv2.imshow("Result",img) cv2.waitKey(0) Getting this error. gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function ‘cv::cvtColor’

Categories
Mastering Development

Loading three.js texture in react as base64 string

I’m using server to generate base64 string representation of charts. Then load it to react component by fetching data with POST request. Data loads to react state but scene renders before texture is loaded. I’ve read Is there a way to wait for THREE.TextureLoader.load() to finish? , should I also use promise ? I would […]

Categories
Mastering Development

Trying to create disappearing squares in Java

class GraphicsExampleComponent extends JComponent { //@Override public void paintComponent(Graphics g) { //make the first call to your recursive routine drawSquare1(g, 0, 0, 80); } public void drawSquare1(Graphics g, int x, int y, int size) { //draw a rectangle g.drawRect(x, y, size, size); g.fillRect(x, y, size, size); //reset the parameters x = x + size + […]

Categories
Mastering Development

Forcing several callbacks to have the same input type without passing generic manually

I have the following (simplified type): interface RequestActionMeta<Data, TransformedData> { getData?: (data: Data, currentData: TransformedData) => TransformedData; } interface RequestAction<Data = any, TransformedData = Data> { type: string; request: any | any[]; meta?: RequestActionMeta<Data, TransformedData>; } declare function createQuery<Data = any, TransformedData = Data ,Variables extends any[] = any[]>( name: string, requestConfig: (…params: Variables) => […]

Categories
Mastering Development

how to gray scale a picture in python using rgb?

I’m writting a function (it has to be called into the main py file later where i take the rgb values, add them, and average them so to get a gray picture. Here is what i have so far: def gray_scale(img,x,y): pixel=img[x][y] r= pixel[0] g=pixel[1] b=pixel[2] return(r+g+b)/3 I have to call this function in my […]

Categories
Mastering Development

Aligning SVG Clip Path on top of image

EDIT: Quick codepen of my current issue: https://codepen.io/zuffdaddy/pen/QWGewKr See how the clip path is massive while the image is small? How do align those two? Original: Intro: I’m making an Attack Disc for a submarine simulator game. The disc has multiple circular rings that all rotate and so far I have that part complete, but […]