MS graph API adaptive card Action.Submit {type: "imBack"} not working on PC teams app - microsoft-graph-api

I'm using graph API to send an Adaptive card containing a number of options, listed as buttons.
and require the text value of the button to be sent back through the chat as if the user sent it.
(using python)
adaptive_card = {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.5",
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"data": {
"msteams": {
"type": "imBack",
"value": "Get Order Status"
}
}
}
]
}
card = {
"subject": None,
"body": {
"contentType": "html",
"content": "<attachment id=\"xxxxxxxxxxxxxxx\"></attachment>"
},
"attachments": [
{
"id": "xxxxxxxxxxxxxxx",
"contentType": "application/vnd.microsoft.card.adaptive",
"content": json.dumps(adaptive_card)
}
]
}
When pressing the button on the adaptive card on the mobile app it works as expected,
though when pressing the button on the PC MS-teams app it does nothing.
as requested, here is the log snippet of the desktop app:
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] useSlotConfigCallbacksAndCustomProperties: Entity options are (incorrectly) being asked for type and action that do not pertain to the entity. chats != chats or view != share, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462173852, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27307440, freeMemory: 4515139584, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] useSlotConfigCallbacksAndCustomProperties: Entity options are (incorrectly) being asked for type and action that do not pertain to the entity. chats != chats or view != share, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 0, scenarioDelta: 0, elapsed: 462173852, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27328756, freeMemory: 4515135488, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] useSlotConfigCallbacksAndCustomProperties: Entity options are (incorrectly) being asked for type and action that do not pertain to the entity. chats != chats or view != share, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462173870, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27367856, freeMemory: 4514861056, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] useSlotConfigCallbacksAndCustomProperties: Entity options are (incorrectly) being asked for type and action that do not pertain to the entity. chats != chats or view != share, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 1, scenarioDelta: 1, elapsed: 462173871, stepDelta: 1, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27382976, freeMemory: 4514861056, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462173887, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27439248, freeMemory: 4514861056, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 0, scenarioDelta: 0, elapsed: 462173887, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27453968, freeMemory: 4514861056, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462174072, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27507816, freeMemory: 4424298496, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 0, scenarioDelta: 0, elapsed: 462174072, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27522680, freeMemory: 4424298496, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462174155, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27567368, freeMemory: 4419440640, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 0, scenarioDelta: 0, elapsed: 462174155, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27582344, freeMemory: 4419440640, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462174185, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27603896, freeMemory: 4415299584, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 0, scenarioDelta: 0, elapsed: 462174185, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27618616, freeMemory: 4415299584, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] chatServiceSubscriptionContainer: convId: 19:<Email>, replyChainId: -1:: cachedMessages is undefined!, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462174200, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27638720, freeMemory: 4415324160, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] chatServiceSubscriptionContainer: convId: 19:<Email>, replyChainId: -1:: cachedMessages is undefined!, status: success, , scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 1, scenarioDelta: 1, elapsed: 462174201, stepDelta: 1, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27653440, freeMemory: 4415324160, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462179444, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27732856, freeMemory: 4287361024, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 0, scenarioDelta: 0, elapsed: 462179444, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27747992, freeMemory: 4287361024, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success,, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462179591, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27823664, freeMemory: 4286967808, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 0, scenarioDelta: 0, elapsed: 462179591, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27838384, freeMemory: 4286963712, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: start, sequence: 0, delta: 0, scenarioDelta: 0, elapsed: 462179841, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27883952, freeMemory: 4284620800, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,
<11088> -- event -- eventpdclevel: 1, errorMessage: https://: line 23: CID[main] ChatPane: consumption horizons mismatch with members - membersConsumptionHorizonLength:1 otherConsumptionHorizonsLength:0 membersLength:2, status: success, scenarioName: experience-renderer-console-error, name: experience-renderer-console-error, step: stop, sequence: 1, delta: 0, scenarioDelta: 0, elapsed: 462179841, stepDelta: 0, Scenario.Mode: 1, AppInfo.Language: en-us, complianceEnvironmentType: 0, isDataCategorizationEnabled: true, userpdclevel: 0, processMemory: 27898816, freeMemory: 4284604416, clientType: desktop, AppInfo.ClientType: desktop, batterylevel: 1, pluggedin: true, Window.Focus: foreground, windowIsVisible: true, Window.Status: systray, UserInfo.TimeZone: +02:00, vdiMode: 0,

Related

How to predict Total Hours needed with List as Input?

I am struggling with the problem I am facing:
I have a dataset of different products (Cars) that have certain Work Orders open at a given time. I know from historical data how much time this work in TOTAL has caused.
Now I want to predict it for another Car (e.g. Car 3).
Which type of algorithm, regression shall I use for this?
My idea was to transform this row based dataset into column based with binary values e.g. Brake: 0/1, Screen 0/1.. But then I will have lots of Inputs as the number of possible Inputs is 100-200..
Here's a quick idea using multi-factor regression for 30 jobs, each of which is some random accumulation of 6 tasks with a "true cost" for each task. We can regress against the task selections in each job to estimate the cost coefficients that best explain the total job costs.
First done w/ no "noise" in the system (tasks are exact), then with some random noise.
A "more thorough" job would include examining the R-squared value and plotting the residuals to ensure linearity.
In [1]: from sklearn import linear_model
In [2]: import numpy as np
In [3]: jobs = np.random.binomial(1, 0.6, (30, 6))
In [4]: true_costs = np.array([10, 20, 5, 53, 31, 42])
In [5]: jobs
Out[5]:
array([[0, 1, 1, 1, 1, 0],
[1, 0, 0, 1, 0, 1],
[1, 1, 0, 1, 0, 0],
[1, 0, 1, 1, 1, 1],
[1, 1, 0, 0, 1, 1],
[0, 1, 0, 0, 1, 0],
[1, 0, 0, 1, 1, 0],
[1, 1, 1, 1, 0, 1],
[1, 0, 0, 1, 0, 1],
[0, 1, 0, 1, 0, 0],
[0, 0, 1, 0, 1, 1],
[1, 0, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[0, 1, 1, 0, 1, 0],
[1, 0, 1, 0, 1, 0],
[1, 1, 1, 1, 1, 1],
[1, 0, 1, 0, 0, 1],
[0, 1, 0, 1, 1, 0],
[1, 1, 1, 0, 1, 0],
[1, 1, 1, 1, 1, 0],
[1, 0, 1, 0, 0, 1],
[0, 0, 0, 1, 1, 1],
[1, 1, 0, 1, 1, 1],
[1, 0, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1],
[0, 0, 1, 1, 0, 0],
[1, 1, 0, 0, 1, 1],
[1, 1, 1, 1, 0, 0]])
In [6]: tot_job_costs = jobs # true_costs
In [7]: reg = linear_model.LinearRegression()
In [8]: reg.fit(jobs, tot_job_costs)
Out[8]: LinearRegression()
In [9]: reg.coef_
Out[9]: array([10., 20., 5., 53., 31., 42.])
In [10]: np.random.normal?
In [11]: noise = np.random.normal(0, scale=5, size=30)
In [12]: noisy_costs = tot_job_costs + noise
In [13]: noisy_costs
Out[13]:
array([113.94632664, 103.82109478, 78.73776288, 145.12778089,
104.92931235, 48.14676751, 94.1052639 , 134.64827785,
109.58893129, 67.48897806, 75.70934522, 143.46588308,
143.12160502, 147.71249157, 53.93020167, 44.22848841,
159.64772255, 52.49447057, 102.70555991, 69.08774251,
125.10685342, 45.79436364, 129.81354375, 160.92510393,
108.59837665, 149.1673096 , 135.12600871, 60.55375843,
107.7925208 , 88.16833899])
In [14]: reg.fit(jobs, noisy_costs)
Out[14]: LinearRegression()
In [15]: reg.coef_
Out[15]:
array([12.09045186, 19.0013987 , 3.44981506, 55.21114084, 33.82282467,
40.48642199])
In [16]:

Metadict in ffmpeg does not have rotate information

My aim is to extract frames out of a video but many times the frames are inverted. This is happening because "VideoCapture" in cv2 does read the rotate flag data present in the video metadata. I am running it on mac and installed "ffmpeg" package (5.0.1) using brew package manager. This is my code to check rotation present in a video using ffmpeg.
import ffmpeg
import cv2
import pprint
pp = pprint.PrettyPrinter(depth=4)
def check_rotation(path_video_file):
# this returns meta-data of the video file in form of a dictionary
meta_dict = ffmpeg.probe(path_video_file)
pp.pprint(meta_dict)
# from the dictionary, meta_dict['streams'][0]['tags']['rotate'] is the key
# we are looking for
rotateCode = None
if int(meta_dict['streams'][0]['tags']['rotate']) == 90:
rotateCode = cv2.ROTATE_90_CLOCKWISE
elif int(meta_dict['streams'][0]['tags']['rotate']) == 180:
rotateCode = cv2.ROTATE_180
elif int(meta_dict['streams'][0]['tags']['rotate']) == 270:
rotateCode = cv2.ROTATE_90_COUNTERCLOCKWISE
return rotateCode
Here the meta_dict is supposed to have information about the rotation but it is not there.
printing out meta_dict gives:
{'format': {'bit_rate': '18498544',
'duration': '3.584000',
'filename': 'video.mp4',
'format_long_name': 'QuickTime / MOV',
'format_name': 'mov,mp4,m4a,3gp,3g2,mj2',
'nb_programs': 0,
'nb_streams': 2,
'probe_score': 100,
'size': '8287348',
'start_time': '0.000000',
'tags': {'com.android.version': '11',
'compatible_brands': 'isommp42',
'creation_time': '2021-12-08T10:56:57.000000Z',
'major_brand': 'mp42',
'minor_version': '0'}},
'streams': [{'avg_frame_rate': '990000/34997',
'bit_rate': '18804651',
'bits_per_raw_sample': '8',
'chroma_location': 'left',
'closed_captions': 0,
'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
'codec_name': 'h264',
'codec_tag': '0x31637661',
'codec_tag_string': 'avc1',
'codec_type': 'video',
'coded_height': 1080,
'coded_width': 1920,
'color_primaries': 'bt470bg',
'color_range': 'pc',
'color_space': 'bt470bg',
'color_transfer': 'smpte170m',
'display_aspect_ratio': '16:9',
'disposition': {'attached_pic': 0,
'captions': 0,
'clean_effects': 0,
'comment': 0,
'default': 1,
'dependent': 0,
'descriptions': 0,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'metadata': 0,
'original': 0,
'still_image': 0,
'timed_thumbnails': 0,
'visual_impaired': 0},
'duration': '3.499700',
'duration_ts': 314973,
'extradata_size': 35,
'field_order': 'progressive',
'film_grain': 0,
'has_b_frames': 0,
'height': 1080,
'id': '0x1',
'index': 0,
'is_avc': 'true',
'level': 40,
'nal_length_size': '4',
'nb_frames': '99',
'pix_fmt': 'yuvj420p',
'profile': 'High',
'r_frame_rate': '120/1',
'refs': 1,
'sample_aspect_ratio': '1:1',
'side_data_list': [{...}],
'start_pts': 3168,
'start_time': '0.035200',
'tags': {'creation_time': '2021-12-08T10:56:57.000000Z',
'handler_name': 'VideoHandle',
'language': 'eng',
'vendor_id': '[0][0][0][0]'},
'time_base': '1/90000',
'width': 1920},
{'avg_frame_rate': '0/0',
'bit_rate': '128986',
'bits_per_sample': 0,
'channel_layout': 'stereo',
'channels': 2,
'codec_long_name': 'AAC (Advanced Audio Coding)',
'codec_name': 'aac',
'codec_tag': '0x6134706d',
'codec_tag_string': 'mp4a',
'codec_type': 'audio',
'disposition': {'attached_pic': 0,
'captions': 0,
'clean_effects': 0,
'comment': 0,
'default': 1,
'dependent': 0,
'descriptions': 0,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'metadata': 0,
'original': 0,
'still_image': 0,
'timed_thumbnails': 0,
'visual_impaired': 0},
'duration': '3.584000',
'duration_ts': 172032,
'extradata_size': 2,
'id': '0x2',
'index': 1,
'nb_frames': '168',
'profile': 'LC',
'r_frame_rate': '0/0',
'sample_fmt': 'fltp',
'sample_rate': '48000',
'start_pts': 0,
'start_time': '0.000000',
'tags': {'creation_time': '2021-12-08T10:56:57.000000Z',
'handler_name': 'SoundHandle',
'language': 'eng',
'vendor_id': '[0][0][0][0]'},
'time_base': '1/48000'}]}
Can someone please help me to find if rotation is present in a video?

Normalizing data that has low variation

I ran several benchmarks on a CPU cache simulation to count the number of the reuse distances (the distance between two accesses of the same cache entry during execution of the program), here are two examples of the data I got from two different benchmarks:
Benchmark 1:
"reuse_dist_counts": {
"-1": 340,
"0": 623,
"1": 930,
"100": 1,
"107": 1,
"114": 1,
"121": 1,
"128": 1,
"135": 1,
"142": 1,
"149": 1,
"156": 1,
"163": 1,
"170": 1,
"177": 1,
"184": 1,
"191": 1,
"198": 1,
"2": 617,
"205": 1,
"212": 1,
"219": 1,
"226": 1,
"233": 1,
"240": 1,
"247": 1,
"254": 1,
"261": 1,
"268": 1,
"275": 1,
"282": 1,
"289": 1,
"296": 1,
"3": 617,
"303": 1,
"310": 1,
"311": 1,
"314": 1,
"4": 1,
"48": 1,
"55": 1,
"62": 1,
"69": 1,
"76": 1,
"79": 1,
"86": 1,
"93": 1
}
Benchmark2:
"reuse_dist_counts": {
"-1": 58,
"0": 128,
"1": 320,
"11": 17,
"12": 1,
"13": 2,
"14": 4,
"15": 18,
"16": 14,
"17": 13,
"18": 13,
"19": 16,
"2": 256,
"20": 16,
"21": 17,
"22": 17,
"23": 2,
"24": 1,
"25": 3,
"26": 3,
"27": 2,
"28": 3,
"29": 2,
"3": 289,
"30": 2,
"31": 2,
"34": 2,
"35": 6,
"38": 2,
"39": 2,
"4": 198,
"40": 4,
"41": 1,
"43": 1,
"44": 2,
"45": 1,
"47": 1,
"48": 2,
"5": 63,
"50": 1,
"6": 81,
"7": 106,
"8": 1
}
it has the form a:b where a is a reuse distance and b is how many times that reuse distance has been found during the execution.
As I'm going to design a neural network based on this data, it's necessary to find a good normalization to represent it in a different way. Any idea on how to normalize such data with such low variations, and how to represent its features vectors?

How to zero pad on both sides and encode the sequence into one hot in keras?

I have text data as follows.
X_train_orignal= np.array(['OC(=O)C1=C(Cl)C=CC=C1Cl', 'OC(=O)C1=C(Cl)C=C(Cl)C=C1Cl',
'OC(=O)C1=CC=CC(=C1Cl)Cl', 'OC(=O)C1=CC(=CC=C1Cl)Cl',
'OC1=C(C=C(C=C1)[N+]([O-])=O)[N+]([O-])=O'])
As it is evident that different sequences have different length. How can I zero pad the sequence on both sides of the sequence to some maximum length. And then convert each sequence into one hot encoding based on each characters?
Try:
I used the following keras API but it doesn't work with strings sequence.
keras.preprocessing.sequence.pad_sequences(sequences, maxlen=None, dtype='int32', padding='pre', truncating='pre', value=0.0)
I might need to convert my sequence data into one hot vectors first and then zero pad it. For that I tried to use Tokanizeas follows.
tk = Tokenizer(nb_words=?, split=?)
But then, what should be the split value and nb_words as my sequence data doesn't have any space? How to use it for character based one hot?
MY overall goal is to zero pad my sequences and convert it to one hot before I feed it into RNN.
So i came across a way to do by using Tokenizer first and then pad_sequences to zero pad my sequence in the start as follows.
from keras.preprocessing.text import Tokenizer
tokenizer = Tokenizer(char_level=True)
tokenizer.fit_on_texts(X_train_orignal)
sequence_of_int = tokenizer.texts_to_sequences(X_train_orignal)
This gives me the output as follows.
[[3, 1, 4, 2, 3, 5, 1, 6, 2, 1, 4, 1, 7, 5, 1, 2, 1, 1, 2, 1, 6, 1, 7],
[3,
1,
4,
2,
3,
5,
1,
6,
2,
1,
4,
1,
7,
5,
1,
2,
1,
4,
1,
7,
5,
1,
2,
1,
6,
1,
7],
[3, 1, 4, 2, 3, 5, 1, 6, 2, 1, 1, 2, 1, 1, 4, 2, 1, 6, 1, 7, 5, 1, 7],
[3, 1, 4, 2, 3, 5, 1, 6, 2, 1, 1, 4, 2, 1, 1, 2, 1, 6, 1, 7, 5, 1, 7],
[3,
1,
6,
2,
1,
4,
1,
2,
1,
4,
1,
2,
1,
6,
5,
8,
10,
11,
9,
4,
8,
3,
12,
9,
5,
2,
3,
5,
8,
10,
11,
9,
4,
8,
3,
12,
9,
5,
2,
3]]
Now I do not understand why it is giving sequence_of_int[1], sequence_of_int[4] output in column format?
After getting the tokens, I applied the pad_sequences as follows.
seq=keras.preprocessing.sequence.pad_sequences(sequence_of_int, maxlen=None, dtype='int32', padding='pre', value=0.0)
and it gives me the output as follows.
array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 3, 1, 4, 2, 3, 5, 1, 6, 2, 1, 4, 1, 7, 5, 1,
2, 1, 1, 2, 1, 6, 1, 7],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 4,
2, 3, 5, 1, 6, 2, 1, 4, 1, 7, 5, 1, 2, 1, 4, 1,
7, 5, 1, 2, 1, 6, 1, 7],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 3, 1, 4, 2, 3, 5, 1, 6, 2, 1, 1, 2, 1, 1, 4,
2, 1, 6, 1, 7, 5, 1, 7],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 3, 1, 4, 2, 3, 5, 1, 6, 2, 1, 1, 4, 2, 1, 1,
2, 1, 6, 1, 7, 5, 1, 7],
[ 3, 1, 6, 2, 1, 4, 1, 2, 1, 4, 1, 2, 1, 6, 5, 8,
10, 11, 9, 4, 8, 3, 12, 9, 5, 2, 3, 5, 8, 10, 11, 9,
4, 8, 3, 12, 9, 5, 2, 3]], dtype=int32)
Then after that, I converted it into one hot as follows.
one_hot=keras.utils.to_categorical(seq)

Disk structuring element in opencv

I know a disk structuring element can be created in MATLAB as following:
se=strel('disk',4);
0 0 1 1 1 0 0
0 1 1 1 1 1 0
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
0 1 1 1 1 1 0
0 0 1 1 1 0 0
Is there any function or method or any other way of creating the structuring element same as above in opencv. I know we can manually create it using loops but I just want to know if some function exist for that.
The closest one (not the exact same) you can get in OpenCV is by calling getStructuringElement():
int sz = 4;
cv::Mat se = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(2*sz-1, 2*sz-1));
, which gives the matrix with values
[0, 0, 0, 1, 0, 0, 0;
0, 1, 1, 1, 1, 1, 0;
1, 1, 1, 1, 1, 1, 1;
1, 1, 1, 1, 1, 1, 1;
1, 1, 1, 1, 1, 1, 1;
0, 1, 1, 1, 1, 1, 0;
0, 0, 0, 1, 0, 0, 0]
def estructurant(radius):
kernel = np.zeros((2*radius+1, 2*radius+1) ,np.uint8)
y,x = np.ogrid[-radius:radius+1, -radius:radius+1]
mask = x**2 + y**2 <= radius**2
kernel[mask] = 1
kernel[0,radius-1:kernel.shape[1]-radius+1] = 1
kernel[kernel.shape[0]-1,radius-1:kernel.shape[1]-radius+1]= 1
kernel[radius-1:kernel.shape[0]-radius+1,0] = 1
kernel[radius-1:kernel.shape[0]-radius+1,kernel.shape[1]-1] = 1
return kernel
try this
You could also use skimage.morphology.disk, which produces a symmetric result (unlike cv2.getStructuringElement):
>>> disk(4)
array([[0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0]], dtype=uint8)

Resources