Showing posts sorted by relevance for query screen orientation. Sort by date Show all posts
Showing posts sorted by relevance for query screen orientation. Sort by date Show all posts

Sunday, 31 May 2020

ionic react screen orientation

page opens in portrait orientation

press landscape to fix screen in landscape orientation

press auto to unlock screen

rotate phone, screen rotates too

press portrait to fix screen in portrait orientation
//cmd

npm install @ionic-native/core
npm install @ionic-native/screen-orientation
npm install cordova-plugin-screen-orientation

---------------------------------------------
//tab3.tsx

import React, { useState, useEffect } from 'react';
import {
  IonContent, IonHeader, IonPage, IonTitle, IonToolbar,
  IonAlert, IonButton, IonCard, IonCardHeader,
  IonCardSubtitle, IonCardTitle, IonCardContent,
  IonItem, IonIcon, IonLabel, IonBadge, IonList,
  IonItemDivider, IonCheckbox, IonFab, IonFabButton,
  IonFabList, IonItemGroup, IonItemSliding,
  IonItemOptions, IonItemOption, IonNote, IonMenu,
  IonRouterOutlet, IonListHeader, IonMenuToggle,
  IonButtons, IonMenuButton, IonInput, IonSplitPane,
  IonPopover, IonSpinner, IonRadioGroup, IonRadio,
  IonRange, IonSearchbar, IonFooter, IonSegmentButton,
  IonSegment, IonToast, IonToggle, IonTextarea
} from '@ionic/react';
import ExploreContainer from '../components/ExploreContainer';
import './Tab3.css';
import {
  call, home, heart, pin, star,
  globe, basket, camera, bookmark
} from 'ionicons/icons';
import { ScreenOrientation } from '@ionic-native/screen-orientation'

const Tab3: React.FC = () => {
  const [oritation, setOritation] = useState<string>('')

  useEffect(() => {
    setOritation(ScreenOrientation.type)
  }, []);

  return (
    <IonPage>
      <IonHeader>
        <IonToolbar>
          <IonTitle>screenOrientation Example</IonTitle>
        </IonToolbar>
      </IonHeader>
      <IonContent>
        <IonList>
          <IonItem>
            <IonButton onClick={() => {
              ScreenOrientation.lock(ScreenOrientation.ORIENTATIONS.PORTRAIT);
              setOritation(ScreenOrientation.ORIENTATIONS.PORTRAIT)
            }}
            >Portrait</IonButton>
            <IonButton onClick={() => {
              ScreenOrientation.lock(ScreenOrientation.ORIENTATIONS.LANDSCAPE);
              setOritation(ScreenOrientation.ORIENTATIONS.LANDSCAPE)
            }}
            >Landscape</IonButton>
            <IonButton onClick={() => {
              ScreenOrientation.unlock();
              setOritation('auto')
            }}
            >Auto</IonButton>
          </IonItem>
          <IonItem>
            <IonLabel>Orientation:</IonLabel>
            {oritation}
          </IonItem>
        </IonList>
      </IonContent>
    </IonPage>

  );
};

export default Tab3;

reference:
https://stackoverflow.com/questions/57787916/what-is-the-right-way-to-use-ionic-native-cordova-plugins-with-ionic-react
https://ionicframework.com/docs/native/screen-orientation

Monday, 19 April 2021

opencv 33 generate ArUco marker

 ArUco markers are used for:
  • Camera calibration
  • Object size estimation
  • Measuring the distance between camera and object
  • 3D position
  • Object orientation
  • Robotics and autonomous navigation
ArUco Tags ID 0 - 9
#main.py
import numpy as np
import argparse
import cv2
import sys

ARUCO_DICT = {
"DICT_4X4_50": cv2.aruco.DICT_4X4_50,
"DICT_4X4_100": cv2.aruco.DICT_4X4_100,
"DICT_4X4_250": cv2.aruco.DICT_4X4_250,
"DICT_4X4_1000": cv2.aruco.DICT_4X4_1000,
"DICT_5X5_50": cv2.aruco.DICT_5X5_50,
"DICT_5X5_100": cv2.aruco.DICT_5X5_100,
"DICT_5X5_250": cv2.aruco.DICT_5X5_250,
"DICT_5X5_1000": cv2.aruco.DICT_5X5_1000,
"DICT_6X6_50": cv2.aruco.DICT_6X6_50,
"DICT_6X6_100": cv2.aruco.DICT_6X6_100,
"DICT_6X6_250": cv2.aruco.DICT_6X6_250,
"DICT_6X6_1000": cv2.aruco.DICT_6X6_1000,
"DICT_7X7_50": cv2.aruco.DICT_7X7_50,
"DICT_7X7_100": cv2.aruco.DICT_7X7_100,
"DICT_7X7_250": cv2.aruco.DICT_7X7_250,
"DICT_7X7_1000": cv2.aruco.DICT_7X7_1000,
"DICT_ARUCO_ORIGINAL": cv2.aruco.DICT_ARUCO_ORIGINAL,
"DICT_APRILTAG_16h5": cv2.aruco.DICT_APRILTAG_16h5,
"DICT_APRILTAG_25h9": cv2.aruco.DICT_APRILTAG_25h9,
"DICT_APRILTAG_36h10": cv2.aruco.DICT_APRILTAG_36h10,
"DICT_APRILTAG_36h11": cv2.aruco.DICT_APRILTAG_36h11
}

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--id", type=int, required=True,
help="ID of ArUCo tag to generate")
ap.add_argument("-t", "--type", type=str,
default="DICT_ARUCO_ORIGINAL",
help="type of ArUCo tag to generate")
args = vars(ap.parse_args())

# verify that the supplied ArUCo tag exists and is supported by OpenCV
if ARUCO_DICT.get(args["type"], None) is None:
print("[INFO] ArUCo tag of '{}' is not supported".format(
args["type"]))
sys.exit(0)

# load the ArUCo dictionary
arucoDict = cv2.aruco.Dictionary_get(ARUCO_DICT[args["type"]])

# allocate memory for the output ArUCo tag and then draw the ArUCo
# tag on the output image
print("[INFO] generating ArUCo tag type '{}' with ID '{}'".format(
args["type"], args["id"]))
tag = np.zeros((300, 300, 1), dtype="uint8")

#drawMarker( dictionary, id, size, image, border bits)
cv2.aruco.drawMarker(arucoDict, args["id"], 300, tag, 1)

# write the generated ArUCo tag to disk and then display it to our
# screen
cv2.imwrite("assets/aurco.png", tag)
name = "ArUCo ID " + str(args["id"])
cv2.imshow(name, tag)
cv2.waitKey(0)

--------------------------
#logs
(venv) C:\Users\zchen\PycharmProjects\opencv>python aruco.py --id 9 --type DICT_5X5_100
[INFO] generating ArUCo tag type 'DICT_5X5_100' with ID '9'

reference: