Display monitor timings calculate - linux

i have such structure, where wrote monitor timings:
[MVDU_MODE_HD_720_P_50] = {
.width = 1280,
.height = 720,
.vmode = MVDU_MODE_PROGRESSIVE,
.pixclock = 74250000,
.mode = 0x17,
.h_blank = 692,
.h_active = 1280,
.h_total = 1980,
.hs_start = 440,
.hs_len = 40,
.hs_delay = 220,
.v_blank_beg = 25,
.v_active = 720,
.v_total = 750,
.v_blank_end = 5,
.vs_start = 0,
.vs_len = 5,
.vs_p = 1,
}
So, and i have fixed
v_total = 780-806;
v-active = 768;
h_total=1,344;
h-active= 1024;
pixclock= 74250000 or 27000000.
How i can calculate other parameters ???

Related

Phaser 3 BitmapText Tint suddenly not working

My code was working just fine one minute and the next it is not.
The issue relates to BitmapText tint.
I am using the CDN for Phaser 3.54.0.
Is there any reason why tint does show? I didn't touch the code relating to BitmapText variables.
This is the code...
export default class CardBase extends Phaser.GameObjects.Container {
constructor(data) {
let { scene, x, y, name, card, image, depth, black, green, purple, red, yellow, products, counter } = data
let spriteCard = new Phaser.GameObjects.Sprite(scene, 0, 0, card)
let spriteImage = new Phaser.GameObjects.Sprite(scene, 0, 20, image)
let textBlack = new Phaser.GameObjects.BitmapText(scene, 80, -120, 'pressstart', black, 20)
let textGreen = new Phaser.GameObjects.BitmapText(scene, 60, -50, 'pressstart', green, 20)
let textPurple = new Phaser.GameObjects.BitmapText(scene, 60, 0, 'pressstart', purple, 20)
let textRed = new Phaser.GameObjects.BitmapText(scene, 60, 50, 'pressstart', red, 20)
let textYellow = new Phaser.GameObjects.BitmapText(scene, 60, 120, 'pressstart', yellow, 20)
let textProducts = new Phaser.GameObjects.BitmapText(scene, 60, -120, 'pressstart', products, 24)
let textCounter = new Phaser.GameObjects.BitmapText(scene, 0, -120, 'pressstart', counter, 36)
textBlack.tint = 0
textGreen.tint = 0
textPurple.tint = 0
textRed.tint = 0
textYellow.tint = 0
textProducts.tint = 0
textCounter.tint = 0
let textName = new Phaser.GameObjects.BitmapText(scene, 0, 0, 'pressstart', name, 16, Phaser.GameObjects.BitmapText.ALIGN_CENTER)
super(scene, x, y, [spriteCard, spriteImage, textName, textBlack, textGreen, textPurple, textRed, textYellow, textProducts, textCounter])
this.spriteCard = spriteCard
this.spriteImage = spriteImage
this.textName = textName
this.cardname = name
this.depth = depth
this.scene = scene
this.textBlack = textBlack
this.textGreen = textGreen
this.textPurple = textPurple
this.textRed = textRed
this.textYellow = textYellow
this.textProducts = textProducts
this.textCounter = textCounter
this.black = black
this.green = green
this.purple = purple
this.red = red
this.yellow = yellow
this.products = products
this.counter = counter
this.scene.add.existing(this)
}
set black(newBlack) {
this._black = newBlack
this.textBlack.text = this._black
}
get black() {
return this._black
}
}
I suspect (I could be wrong) my problem is related to my browser. I had updates due on Chrome. It turned out that Phaser.AUTO was defaulting to Canvas instead of WebGL. It seemed that WebGL was not available somehow.
Since BitmapText Tint only works on WebGL, it was affected when WebGL became unavailable. It couldn't work.
After I restarted my computer and the updates on Chrome took effect, everything went back to normal and Tint worked again.

How can I get a vector to hold previous value in the code

I want "NewSignals" to be set to 0 when Profit >= 2 AND stay zero until a change in "Signals"
ndf = pd.DataFrame()
ndf['Signals'] = [0,0,1,1,1,1,1,1,-1,-1,1,1,1]
signals_diff = ndf.Signals.diff()
ndf['Revals'] = [101,102,105,106,107,106,107,105,109,109,108,107,106]
ndf['Entry'] = ndf.Revals.where(signals_diff != 0).ffill()
ndf['EntrySignal'] = ndf.Signals.where(signals_diff != 0).ffill()
ndf['Profit'] = (ndf.Revals - ndf.Entry) * ndf.EntrySignal
ndf['NewSignals'] = ndf.Signals.where(ndf.Profit < 2.0, other=0)
print (ndf)
My wanted output is in WANTNewSignals
It's very simple. Just compare Profit and Signals and based on that you can choose what to put in wanted signals. Look at the code below it will serve your purpose i hope.
import pandas as pd
ndf = pd.DataFrame()
ndf['Signals'] = [0, 0, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1]
signals_diff = ndf.Signals.diff()
ndf['Revals'] = [101, 102, 105, 106, 107, 106, 107, 105, 109, 109, 108, 107, 106]
ndf['Entry'] = ndf.Revals.where(signals_diff != 0).ffill()
ndf['EntrySignal'] = ndf.Signals.where(signals_diff != 0).ffill()
ndf['Profit'] = (ndf.Revals - ndf.Entry) * ndf.EntrySignal
ndf['NewSignals'] = ndf.Signals.where(ndf.Profit < 2.0, other=0)
print(ndf)
signals = list(ndf['Signals'])
profit = list(ndf['Profit'] )
print(signals)
NewSignals = []
keep_0 = False
for index, value in enumerate(profit):
if value >= 2:
NewSignals.append(0)
keep_0 = True
else:
condition = signals[index] == signals[index - 1]
if keep_0 and condition:
new_value = 0 if condition else signals[index]
NewSignals.append(new_value)
else:
NewSignals.append(signals[index])
keep_0 = False
ndf['WantedSignals'] = NewSignals
print(ndf)

How to get real Landsat image conrers

How I can get actual coordinates of Landsat image corners (see image to understand) ?
From metadata file (..._MTL.txt) I can get coordinates of red corners, but I need to get coordinates of green corners.
I work with GeoTIFF files using GDAL.
I need to get correct latitude and longitude of green points.
Can I do it using python3?
Thanks for help
Metadata file
GROUP = L1_METADATA_FILE
GROUP = METADATA_FILE_INFO
ORIGIN = "Image courtesy of the U.S. Geological Survey"
REQUEST_ID = "9991103150002_00325"
PRODUCT_CREATION_TIME = 2011-03-16T20:14:24Z
STATION_ID = "EDC"
LANDSAT5_XBAND = "1"
GROUND_STATION = "IKR"
LPS_PROCESSOR_NUMBER = 0
DATEHOUR_CONTACT_PERIOD = "1016604"
SUBINTERVAL_NUMBER = "01"
END_GROUP = METADATA_FILE_INFO
GROUP = PRODUCT_METADATA
PRODUCT_TYPE = "L1T"
ELEVATION_SOURCE = "GLS2000"
PROCESSING_SOFTWARE = "LPGS_11.3.0"
EPHEMERIS_TYPE = "DEFINITIVE"
SPACECRAFT_ID = "Landsat5"
SENSOR_ID = "TM"
SENSOR_MODE = "BUMPER"
ACQUISITION_DATE = 2010-06-15
SCENE_CENTER_SCAN_TIME = 04:57:44.2830500Z
WRS_PATH = 145
STARTING_ROW = 26
ENDING_ROW = 26
BAND_COMBINATION = "1234567"
PRODUCT_UL_CORNER_LAT = 49.8314223
PRODUCT_UL_CORNER_LON = 84.0018859
PRODUCT_UR_CORNER_LAT = 49.8694055
PRODUCT_UR_CORNER_LON = 87.4313889
PRODUCT_LL_CORNER_LAT = 47.8261840
PRODUCT_LL_CORNER_LON = 84.1192898
PRODUCT_LR_CORNER_LAT = 47.8615913
PRODUCT_LR_CORNER_LON = 87.4144676
PRODUCT_UL_CORNER_MAPX = 284400.000
PRODUCT_UL_CORNER_MAPY = 5524200.000
PRODUCT_UR_CORNER_MAPX = 531000.000
PRODUCT_UR_CORNER_MAPY = 5524200.000
PRODUCT_LL_CORNER_MAPX = 284400.000
PRODUCT_LL_CORNER_MAPY = 5301000.000
PRODUCT_LR_CORNER_MAPX = 531000.000
PRODUCT_LR_CORNER_MAPY = 5301000.000
PRODUCT_SAMPLES_REF = 8221
PRODUCT_LINES_REF = 7441
PRODUCT_SAMPLES_THM = 4111
PRODUCT_LINES_THM = 3721
BAND1_FILE_NAME = "L5145026_02620100615_B10.TIF"
BAND2_FILE_NAME = "L5145026_02620100615_B20.TIF"
BAND3_FILE_NAME = "L5145026_02620100615_B30.TIF"
BAND4_FILE_NAME = "L5145026_02620100615_B40.TIF"
BAND5_FILE_NAME = "L5145026_02620100615_B50.TIF"
BAND6_FILE_NAME = "L5145026_02620100615_B60.TIF"
BAND7_FILE_NAME = "L5145026_02620100615_B70.TIF"
GCP_FILE_NAME = "L5145026_02620100615_GCP.txt"
METADATA_L1_FILE_NAME = "L5145026_02620100615_MTL.txt"
CPF_FILE_NAME = "L5CPF20100401_20100630_09"
END_GROUP = PRODUCT_METADATA
GROUP = MIN_MAX_RADIANCE
LMAX_BAND1 = 193.000
LMIN_BAND1 = -1.520
LMAX_BAND2 = 365.000
LMIN_BAND2 = -2.840
LMAX_BAND3 = 264.000
LMIN_BAND3 = -1.170
LMAX_BAND4 = 221.000
LMIN_BAND4 = -1.510
LMAX_BAND5 = 30.200
LMIN_BAND5 = -0.370
LMAX_BAND6 = 15.303
LMIN_BAND6 = 1.238
LMAX_BAND7 = 16.500
LMIN_BAND7 = -0.150
END_GROUP = MIN_MAX_RADIANCE
GROUP = MIN_MAX_PIXEL_VALUE
QCALMAX_BAND1 = 255.0
QCALMIN_BAND1 = 1.0
QCALMAX_BAND2 = 255.0
QCALMIN_BAND2 = 1.0
QCALMAX_BAND3 = 255.0
QCALMIN_BAND3 = 1.0
QCALMAX_BAND4 = 255.0
QCALMIN_BAND4 = 1.0
QCALMAX_BAND5 = 255.0
QCALMIN_BAND5 = 1.0
QCALMAX_BAND6 = 255.0
QCALMIN_BAND6 = 1.0
QCALMAX_BAND7 = 255.0
QCALMIN_BAND7 = 1.0
END_GROUP = MIN_MAX_PIXEL_VALUE
GROUP = PRODUCT_PARAMETERS
CORRECTION_METHOD_GAIN_BAND1 = "CPF"
CORRECTION_METHOD_GAIN_BAND2 = "CPF"
CORRECTION_METHOD_GAIN_BAND3 = "CPF"
CORRECTION_METHOD_GAIN_BAND4 = "CPF"
CORRECTION_METHOD_GAIN_BAND5 = "CPF"
CORRECTION_METHOD_GAIN_BAND6 = "IC"
CORRECTION_METHOD_GAIN_BAND7 = "CPF"
CORRECTION_METHOD_BIAS = "IC"
SUN_AZIMUTH = 141.2669762
SUN_ELEVATION = 59.9909680
OUTPUT_FORMAT = "GEOTIFF"
END_GROUP = PRODUCT_PARAMETERS
GROUP = CORRECTIONS_APPLIED
STRIPING_BAND1 = "NONE"
STRIPING_BAND2 = "NONE"
STRIPING_BAND3 = "NONE"
STRIPING_BAND4 = "NONE"
STRIPING_BAND5 = "NONE"
STRIPING_BAND6 = "NONE"
STRIPING_BAND7 = "NONE"
BANDING = "N"
COHERENT_NOISE = "N"
MEMORY_EFFECT = "Y"
SCAN_CORRELATED_SHIFT = "Y"
INOPERABLE_DETECTORS = "N"
DROPPED_LINES = "N"
END_GROUP = CORRECTIONS_APPLIED
GROUP = PROJECTION_PARAMETERS
REFERENCE_DATUM = "WGS84"
REFERENCE_ELLIPSOID = "WGS84"
GRID_CELL_SIZE_THM = 60.000
GRID_CELL_SIZE_REF = 30.000
ORIENTATION = "NUP"
RESAMPLING_OPTION = "CC"
MAP_PROJECTION = "UTM"
END_GROUP = PROJECTION_PARAMETERS
GROUP = UTM_PARAMETERS
ZONE_NUMBER = 45
END_GROUP = UTM_PARAMETERS
END_GROUP = L1_METADATA_FILE
END
You might first find the contour with the biggest area. Then try some algorithm to find the points you want. It seems that the satellite picture in the image is not a perfect rectangle, so you can't fit a rectangle on it using OpenCV's built-in methods.
You should try something like that:
import cv2
import numpy as np
img = cv2.imread('z_edited.jpg')
imgray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(imgray, (11, 11), 0)
ret, thresh = cv2.threshold(blurred, 27, 255, 0)
cnts, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
max_area = 0
max_area_index = 0
for i, cnt in enumerate(cnts):
area = cv2.contourArea(cnt)
if area > max_area:
max_area = area
max_area_index = i
x_min = np.min(cnts[max_area_index][:, 0, 0])
x_max = np.max(cnts[max_area_index][:, 0, 0])
y_min = np.min(cnts[max_area_index][:, 0, 1])
y_max = np.max(cnts[max_area_index][:, 0, 1])
(x_left, y_left) = (x_min, cnts[max_area_index][np.max(np.where(cnts[max_area_index][:, 0, 0] == x_min)), 0, 1])
(x_right, y_right) = (x_max, cnts[max_area_index][np.max(np.where(cnts[max_area_index][:, 0, 0] == x_max)), 0, 1])
(x_down, y_down) = (cnts[max_area_index][np.max(np.where(cnts[max_area_index][:, 0, 1] == y_max)), 0, 0], y_max)
(x_top, y_top) = (cnts[max_area_index][np.max(np.where(cnts[max_area_index][:, 0, 1] == y_min)), 0, 0], y_min)
cv2.circle(img, (x_left, y_left), 10, (0, 0, 255), thickness=8)
cv2.circle(img, (x_right, y_right), 10, (0, 0, 255), thickness=8)
cv2.circle(img, (x_down, y_down), 10, (0, 0, 255), thickness=8)
cv2.circle(img, (x_top, y_top), 10, (0, 0, 255), thickness=8)
# cv2.drawContours(img, cnts, max_area_index, (0, 255, 0), 2)
cv2.namedWindow('s', cv2.WINDOW_NORMAL)
cv2.imshow('s', img)
cv2.waitKey(0)
And the result looks like:
Using this code you can find the coordinates of the corners of the satellite picture inside the image(red points).
Also need to say I have assumed that your satellite picture background is completely black(the image you have uploaded, has a thin gray strip around the whole image).

Tkinter Frame and griding

I am designing a front end using Tkinter but the .grid() option doesn't work as expected. I want to divide my screen to two section, LEFT and Right. All the buttons and labels on the left and the rest on the right.
# Initialise frames
self.frame_left = tk.Frame(root, bg = "pink", width = 100, height = 100).grid(row = 0, column = 0, sticky = 'E')
self.frame_right = tk.Frame(root, bg = "red", width = 100, height = 100).grid(row = 0, column = 1, sticky = 'W')
root.grid_columnconfigure(0, weight=0)
root.grid_columnconfigure(1, weight=0)
#labels
self.Name_Label = tk.Label(self.frame_left, text = "Name", font = 12, fg = 'green').grid(row = 1, column = 1)
self.Phone_Label = tk.Label(self.frame_left, text = "Phone Number", font = 12, fg= 'green').grid(row = 1, column =2)
self.University_label = tk.Label(self.frame_left, text = "University", font = 12, fg = 'green').grid(row = 1, column = 3)
#Search boxex
self.Name_box = tk.Entry(self.frame_left, width = 12, borderwidth = 2).grid(row = 2, column = 1)
self.Phone_box = tk.Entry(self.frame_left, width = 12, borderwidth = 2).grid(row = 2, column = 2)
self.Phone_box = tk.Entry(self.frame_left, width = 12, borderwidth = 2).grid(row = 2, column = 3)
# Buttons
self.Search_button = tk.Button(self.frame_left, text='Search', padx = 10, pady = 10, font = 12, fg = 'black').grid(row = 5, column = 1)
#Screen
#self.Screen = tk.Listbox(self.frame_right, width = 20, height = 20, font = 1).grid(row = 0, column = 0)
It seems the labels and buttons are being placed on the root window not the frames that has been defined.
Appreciate your help.
Regards
Khisrow
To divide your screen into 2 parts, you need to use the option columnconfigure:
root.columnconfigure(0, weight=1)
root.columnconfigure(1, weight=1)
This creates a grid on the root window with 2 columns in which your self.frame_left and self.frame_right can be placed.
When you store a .grid() item you are not storing the widget:
self.frame_left = tk.Frame(root, bg = "pink", width = 100, height = 100).grid(row = 0, column = 0, sticky = 'E')
Stores the grid object to the variable, not the Frame.
This can be fixed by doing the creation and grid in two lines.
import tkinter as tk
class Test():
def __init__(self):
root = tk.Tk()
#EXAMPLE OF DIFFERENCE
self.frame_left = tk.Frame(root, bg = "pink", width = 100, height = 100).grid(row = 0, column = 0, sticky = 'E')
print(self.frame_left, "DIDN'T STORE THE FRAME")
self.frame_left = tk.Frame(root, bg = "pink", width = 100, height = 100)
self.frame_left.grid(row = 0, column = 0, sticky = 'E')
print(self.frame_left, "STORED THE FRAME")
#EXAMPLE OF DIFFERENCE
# Initialise frames
self.frame_left = tk.Frame(root, bg = "pink", width = 100, height = 100)
self.frame_left.grid(row = 0, column = 0, sticky = 'E')
self.frame_right = tk.Frame(root, bg = "red", width = 100, height = 100)
self.frame_right.grid(row = 0, column = 1, sticky = 'W')
root.grid_columnconfigure(0, weight=0)
root.grid_columnconfigure(1, weight=0)
#labels
self.Name_Label = tk.Label(self.frame_left, text = "Name", font = 12, fg = 'green').grid(row = 1, column = 1)
self.Phone_Label = tk.Label(self.frame_left, text = "Phone Number", font = 12, fg= 'green').grid(row = 1, column =2)
self.University_label = tk.Label(self.frame_left, text = "University", font = 12, fg = 'green').grid(row = 1, column = 3)
#Search boxex
self.Name_box = tk.Entry(self.frame_left, width = 12, borderwidth = 2)
self.Name_box.grid(row = 2, column = 1)
self.Phone_box = tk.Entry(self.frame_left, width = 12, borderwidth = 2)
self.Phone_box.grid(row = 2, column = 2)
self.Phone_box = tk.Entry(self.frame_left, width = 12, borderwidth = 2)
self.Phone_box.grid(row = 2, column = 3)
# Buttons
self.Search_button = tk.Button(self.frame_left, text='Search', padx = 10, pady = 10, font = 12, fg = 'black').grid(row = 5, column = 1)
#Screen
#self.Screen = tk.Listbox(self.frame_right, width = 20, height = 20, font = 1).grid(row = 0, column = 0)
Test()
EDIT: added a listbox with scrollbar
# Screen
scrollbar = tk.Scrollbar(self.frame_right)
scrollbar.grid(row = 0, column = 1, sticky = 'nsw')
self.Screen = tk.Listbox(self.frame_right, width = 20, height = 5, font = 1)
self.Screen.grid(row = 0, column = 0, sticky = 'e')
self.Screen.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.Screen.yview)

What would I need to write if I wanted to make a timer cancel based on the increasing of the score? (Corona)

I'm trying to cancel a timer when the player chooses the correct character. I have come to the conclusion that the two possible ways to do this are to cancel the timer based on the increase of the score, or on the initialization of the addEventListener. I have tried to fiddle around with some possible options, but none of them worked. Any ideas on what to write to make the condition viable so that the timer will cancel based on such event happening? here is the code I have thus far:
function timeClock(event)
if event.time > 2000 then
storyboard.gotoScene( "restartEasy" )
randomImage.alpha = 0
else
timer.cancel( event.source )
end
end
function endGame(event)
if imageFile == "redbox.png" then
timer.performWithDelay( 2000, timeClock )
randomImage.alpha = 0
mydata.score = mydata.score + 1
scoreText.text = mydata.score
button1.x = math.random( 55, 300)
button1.y = math.random( 55, 300)
button2.x = math.random( 55, 300)
button2.y = math.random( 55, 300)
imageFile = imageFiles[math.random(2)]
randomImage = display.newImage(imageFile, centerX, screenTop + 20)
storyboard.gotoScene( "restartEasy" )
randomImage.alpha = 0
end
end
function endGame2(event)
if imageFile == "bluebox.png" then
timer.performWithDelay( 2000, timeClock )
randomImage.alpha = 0
mydata.score = mydata.score + 1
scoreText.text = mydata.score
button1.x = math.random( 55, 300)
button1.y = math.random( 55, 300)
button2.x = math.random( 55, 300)
button2.y = math.random( 55, 300)
imageFile = imageFiles[math.random(2)]
randomImage = display.newImage(imageFile, centerX, screenTop + 20)
else
storyboard.gotoScene( "restartEasy" )
randomImage.alpha = 0
end
end
button1:addEventListener("touch", endGame)
button2:addEventListener("touch", endGame2)
end
Name the timer a public variable for instance
timer1 = timer.performWithDelay(2000, timeClock)
Then in your function cancel the timer using
timer.cancel(timer1)

Resources