技術情報

DataTablesを使用したテーブル生成とサーバーサイド連携(8)

本記事ではDataTablesを使用したテーブル生成方法とサーバーサイド連携方法をシェアします。
前回の記事でページングおよびソート処理の実装が完了しましたので
今回は検索(フィルタリング)処理の作成をおこなっていきたいと思います。

続きを読む

6 Tips for optimizing a laravel application

Today, I would like to share about some tips for optimizing a laravel application. Let’s take a look.

1. Cache routes, config and views

Caching speeds up your application. This is important when deploying a application to a production environment.

To cache your routes, you can use the following command:
php artisan route:cache

To clear the route cache, you can use the following command:
php artisan route:clear

To cache config, you can use the following command:

php artisan config:cache

To cache your views, you can use the following command:

php artisan view:cache

2. Remove unused services

You should remove unused services when the application grows. This can be done by removing the service from the config/app.php file.

3. Remove unused packages

To keep the app clean, you should remove unused packages from the application. This can be done by removing the package from the composer.json file or by running the following command:

composer remove package-name

4. Remove development dependencies

You should also remove development dependencies when deploying to production. This can be done by running the following command:

composer install –prefer-dist –no-dev -o

5. Composer Autoload Optimization

For your applications, you should use the composer autoload optimization feature as the autoloader can take significant time for each request:

composer dumpautoload -o

The -o flag will convert PSR-0/4 autoloading to classmap to become a faster autoloader.

6. Precompile your assets

If npm is used for your front-end development, you should precompile your assets. This can be done by running the following command:

npm run production

This will compile the assets and create public/assets directory.

This is all for now. Hope you enjoy that.

By Asahi



知っておいていただきたいこと – 1

今回は、知っておいた方がいいとおもったことをいくつか紹介します。

Tip – 1

APIやajaxリクエストのレスポンスとしてデータを返したくない場合は、簡単にnoContent()メソッドを使用することができます。非常にクリーンで、データなしの成功レスポンスを返すのに非常に便利です。

#HTTP, #PHP

public function update(){
  return response()->noContent();
}

Tip – 2

Laravel 9.xで新しい追加こと 「whenTableHasColumnwhenTableDoesntHaveColumn

この関数は、移行時にテーブルのカラムの更新を行うためのこと

//マイグレーション.アップ
 Schema::whenTableDoesntHaveColumn('product', 'order', function (Blueprint $table) {
            $table->unsignedInteger('order')->default(0);
        });

 //マイグレーション.ダウン
        Schema::whenTableHasColumn('product', 'order', function (Blueprint $table) {
            $table->dropColumn('order');
        });

ということで、今回はこれで終わります。

金担当 – Ami



DataTablesを使用したテーブル生成とサーバーサイド連携(7)

本記事ではDataTablesを使用したテーブル生成方法とサーバーサイド連携方法をシェアします。
前回の記事でページング処理ができましたので、今回はデータテーブルの各項目にソート処理を追加していきたいと思います。

続きを読む

Basic HandTracking in Python, OpenCV using mediapipe

Today I would like to share about tracking hands in python and opencv using mediapipe library.

Let’s take a look.

OpenCV is a tool for image processing and performing computer vision tasks. It is an open-source library that can be used to perform tasks like face detection, objection tracking, landmark detection, and much more. It supports multiple languages including python, java C++.

MediaPipe is Google’s open-source framework for media processing. It is cross-platform that can run on Android, iOS, web.

First of all, we will import required libraries in line 1 to 3.

Next, in line 6, we need to create a VideoCapture Object to capture a video from a webcam.

And if not found camera, info message is displayed in line 9.

Then in line 14 to 16, we will call the methods of MediaPipe and create a Hands() object to detect handlandmarks.

Next, in line 21, while camera is opened, we will handle hand tracking processes .

In line 22 and 23, read the images from the camera and convert the images to RGB images because we will have to pass only RGB images in hands.process(imgRGB) of line 25.

In line 26, we can get hand Landmarks easily by the help of mediapipe. If we print landmarks, we will see they are coordinates in line 27.

And we need to draw every hand landmarks by using drawing_utils of mediapipe in line 29 to 31.

And we will also show the frame rate of the camera. So we will calculate fps with cTime(current time) and pTime(previous time) by using time library in line 33 and 35. Before that, firstly cTime and pTime are also needed to assign into 0 in line 18 and 19.

Then we will write fps value on the display capture in line 37.

Finally, in line 39 and 40, we output the live capture.

There we go.

So this is all for now. For further details information, here are the reference links.

https://docs.opencv.org/4.x/d6/d00/tutorial_py_root.html

https://google.github.io/mediapipe/getting_started/python.html

Hope you enjoy that.

By Asahi




アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム