【FLUTTER ANDROID STUDIO and IOS】Dio Http Cache Posted: 02 May 2021 09:24 AM PDT import 'package:dio/dio.dart'; import 'package:dio_http_cache/dio_http_cache.dart'; import 'package:flutter/material.dart';
void main() { runApp(MyApp()); }
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter cache with dio', home: MyHomePage(), ); } }
class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); }
class _MyHomePageState extends State<MyHomePage> { DioCacheManager _dioCacheManager; String _myData;
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: ListView( children: [ FlatButton( child: Text( 'getData', ), onPressed: () async { _dioCacheManager = DioCacheManager(CacheConfig());
Options _cacheOptions = buildCacheOptions(Duration(days: 7), forceRefresh: true); Dio _dio = Dio(); _dio.interceptors.add(_dioCacheManager.interceptor); Response response = await _dio.get( 'https://jsonplaceholder.typicode.com/users', options: _cacheOptions); setState(() { _myData = response.data.toString(); }); print(_myData); }, ), FlatButton( child: Text( 'Delete Cache', ), onPressed: () async { if (_dioCacheManager != null) { bool res = await _dioCacheManager.deleteByPrimaryKey( 'https://jsonplaceholder.typicode.com/users'); print(res); } }, ), Text( _myData ?? '',
), ], ), ); } } |
【JAVASCRIPT】 change order payment request api Posted: 02 May 2021 09:21 AM PDT |
【PYTHON OPENCV】Image classification OpenCV CNN module using GoogLeNet and caffe pre trained models Posted: 02 May 2021 09:14 AM PDT """ Image classification using OpenCV CNN module using GoogLeNet and caffe pre-trained models bvlc_googlenet.prototxt: https://github.com/opencv/opencv_extra/blob/master/testdata/dnn/bvlc_googlenet.prototxtbvlc_googlenet.caffemodel: http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel""" # Import required packages:import cv2import numpy as npfrom matplotlib import pyplot as plt def show_img_with_matplotlib(color_img, title, pos): """Shows an image using matplotlib capabilities""" img_RGB = color_img[:, :, ::-1] ax = plt.subplot(1, 1, pos) plt.imshow(img_RGB) plt.title(title) plt.axis('off') # Load the names of the classes:rows = open('synset_words.txt').read().strip().split('\n')classes = [r[r.find(' ') + 1:].split(',')[0] for r in rows] # Load the serialized caffe model from disk:net = cv2.dnn.readNetFromCaffe("bvlc_googlenet.prototxt", "bvlc_googlenet.caffemodel") # Load input image:image = cv2.imread("church.jpg") # Create the blob with a size of (224,224), mean subtraction values (104, 117, 123)blob = cv2.dnn.blobFromImage(image, 1, (224, 224), (104, 117, 123))print(blob.shape) # Feed the input blob to the network, perform inference and ghe the output:net.setInput(blob)preds = net.forward() # Get inference time:t, _ = net.getPerfProfile()print('Inference time: %.2f ms' % (t * 1000.0 / cv2.getTickFrequency())) # Get the 10 indexes with the highest probability (in descending order)# This way, the index with the highest prob (top prediction) will be the first:indexes = np.argsort(preds[0])[::-1][:10] # We draw on the image the class and probability associated with the top prediction:text = "label: {}\nprobability: {:.2f}%".format(classes[indexes[0]], preds[0][indexes[0]] * 100)y0, dy = 30, 30for i, line in enumerate(text.split('\n')): y = y0 + i * dy cv2.putText(image, line, (5, y), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 255), 2) # Print top 10 prediction:for (index, idx) in enumerate(indexes): print("{}. label: {}, probability: {:.10}".format(index + 1, classes[idx], preds[0][idx])) # Create the dimensions of the figure and set title:fig = plt.figure(figsize=(10, 6))plt.suptitle("Image classification with OpenCV using GoogLeNet and caffe pre-trained models", fontsize=14,fontweight='bold')fig.patch.set_facecolor('silver') # Show the output image:show_img_with_matplotlib(image, "GoogLeNet and caffe pre-trained models", 1) # Show the Figure:plt.show() |
【GAMEMAKER】Usable Items Posted: 02 May 2021 09:09 AM PDT Information about object: obj_brown_chest Sprite: spr_brown_chest Solid: false Visible: true Depth: 0 Persistent: false Parent: obj_chest_parent Children: Mask:
No Physics Object Create Event: execute code:
my_id=1; image_speed=0; image_index=0;
Information about object: obj_brown_key
Sprite: spr_brown_key Solid: false Visible: true Depth: 0 Persistent: false Parent: obj_pick_up_parent Children: Mask:
No Physics Object
Create Event: execute code:
my_id=1;
Information about object: obj_chest_parent
Sprite: Solid: false Visible: true Depth: 0 Persistent: false Parent:
Children obj_brown_chest obj_green_chest obj_red_chest
Mask:
No Physics Object
Information about object: obj_green_chestSprite: spr_green_chest Solid: false Visible: true Depth: 0 Persistent: false Parent: obj_chest_parent Children: Mask:
No Physics Object Create Event: execute code:
my_id=3; image_speed=0; image_index=0;
Information about object: obj_green_key
Sprite: spr_green_key Solid: false Visible: true Depth: 0 Persistent: false Parent: obj_pick_up_parent Children: Mask:
No Physics Object
Create Event: execute code:
my_id=3;
Information about object: obj_invbutton
Sprite: Solid: false Visible: true Depth: -1001 Persistent: false Parent: Children: Mask:
No Physics Object
Draw Event: execute code:
var item = global.inventory[slot]; var click = mouse_check_button_pressed(mb_left);
if (abs(mouse_x - x) < 30) && (abs(mouse_y- y) < 38) { draw_set_colour(c_white); draw_rectangle(x-28,y-28,x+28,y+28,0); if (click) { if (item != -1) { scr_itemdrop_slot(slot); } if (global.mouseItem != -1) { scr_itempickup_slot(global.mouseItem,slot) } global.mouseItem = item; } if mouse_check_button_pressed(mb_right) { switch (global.inventory[slot]) { case 1: instance_create(obj_player.x,obj_player.y,obj_brown_key); break; case 2: instance_create(obj_player.x,obj_player.y,obj_red_key); break; case 3: instance_create(obj_player.x,obj_player.y,obj_green_key); break; } //remove item from inventory global.inventory[slot]=-1; } }
if (item != -1) { draw_sprite(spr_items,item,x,y); }
Information about object: obj_inventory
Sprite: Solid: false Visible: true Depth: -1000 Persistent: true Parent: Children: Mask:
No Physics Object
Create Event: execute code:
///Set Up
global.maxItems=2;//total item slots
for (var i = 0; i < 2; i += 1) { global.inventory[i] = -1; button[i] = instance_create(0,0,obj_invbutton) button[i].slot = i; }
global.mouseItem=-1; instance_create(0,0,obj_mouseitem);
Draw Event: execute code:
///draw the inventory var x1,x2,y1,y2; x1 = view_xview[0]+75; x2 = x1 + view_wview[0]; y1 = view_yview[0]+30; y2 = y1 + 64;
draw_set_color(c_black); draw_set_alpha(0.8); draw_sprite(spr_inv_bg,0,x1,y1-25); for (var i = 0; i < global.maxItems; i += 1) { var ix = x1+64+(i * 60); var iy = y2-48;
draw_sprite(spr_border,0,ix,iy) button[i].x = ix; button[i].y = iy; } draw_text(x1+100,y1+200,"P To Pick Up An Item When Touching# Click and Drag To Move & Use # Right Click To Drop");
Information about object: obj_mouseitem
Sprite: spr_collision Solid: false Visible: true Depth: -1002 Persistent: false Parent: Children: Mask:
No Physics Object
Collision Event with object obj_chest_parent: execute code:
if other.my_id==global.mouseItem { with (other){ image_index=1; //instance_destroy(); } }
Draw Event: execute code:
var item=global.mouseItem; if (item != -1) { x = mouse_x; y = mouse_y; draw_sprite(spr_items,item,x,y); }
Information about object: obj_pick_up_parent
Sprite: Solid: false Visible: true Depth: 0 Persistent: false Parent:
Children obj_brown_key obj_green_key obj_red_key
Mask:
No Physics Object
Collision Event with object obj_player: execute code:
///Detect Keypress & Check For Empty Slot if keyboard_check_pressed(ord('P')) { if scr_itempickup(my_id)//if slot available, add to slot { instance_destroy();//then destroy instance] } else { switch (global.inventory[0]) { case 1: instance_create(obj_player.x+50,obj_player.y,obj_brown_key); break; case 2: instance_create(obj_player.x+50,obj_player.y,obj_red_key); break; case 3: instance_create(obj_player.x+50,obj_player.y,obj_green_key); break; global.inventory[0]=-1; scr_itempickup(my_id); instance_destroy(); } } }
Information about object: obj_player
Sprite: spr_idle_down Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask:
No Physics Object
Create Event: execute code:
///set up enum player_state { idle, up, down, left, right }
dir=player_state.down; is_moving=false; image_speed=0.5;
Step Event: execute code:
///keypress code if (keyboard_check(vk_left)) { dir=player_state.left; is_moving=true; } else if (keyboard_check(vk_right)) { dir=player_state.right; is_moving=true; } else if (keyboard_check(vk_up)) { dir=player_state.up; is_moving=true; } else if (keyboard_check(vk_down)) { dir=player_state.down; is_moving=true; } else { is_moving=false; }
execute code:
///movement if is_moving { switch (dir) { case player_state.up: y -= 4; break;
case player_state.down: y += 4; break;
case player_state.left: x -= 4; break; case player_state.right: x += 4; break; } }
execute code:
///animation if is_moving { switch (dir) { case player_state.up: sprite_index=spr_walk_up; break;
case player_state.down: sprite_index=spr_walk_down; break;
case player_state.left: sprite_index=spr_walk_left; break; case player_state.right: sprite_index=spr_walk_right; break; } } else { switch (dir) { case player_state.up: sprite_index=spr_idle_up; break;
case player_state.down: sprite_index=spr_idle_down; break;
case player_state.left: sprite_index=spr_idle_left; break; case player_state.right: sprite_index=spr_idle_right; break; } }
Information about object: obj_red_chest
Sprite: spr_red_chest Solid: false Visible: true Depth: 0 Persistent: false Parent: obj_chest_parent Children: Mask:
No Physics Object
Create Event: execute code:
my_id=2; image_speed=0; image_index=0;
Information about object: obj_red_key
Sprite: spr_red_key Solid: false Visible: true Depth: 0 Persistent: false Parent: obj_pick_up_parent Children: Mask:
No Physics Object
Create Event: execute code:
my_id=2;
|
【JAVASCRIPT】picture comparison Posted: 02 May 2021 04:49 AM PDT |
【JAVASCRIPT】canvas to draw coordinates and lines Posted: 02 May 2021 04:43 AM PDT |
【JAVASCRIPT】2048 mini game Posted: 02 May 2021 04:37 AM PDT |
No comments:
Post a Comment