技術情報

Resizing the image to a specific width and height with opencv in Python

Today, I would like to share a program for resizing the images to a specific width and height with opencv library in Python. Let’s take a look.

Opencv has resize method cv2.resize() to resize the images.

We can resize the images simply as follows.

import cv2

# read the input
img = cv2.imread('input.jpeg')
height, width, channel = img.shape
print(f"Height and width of original image: {height}, {width}")

# resize the image
new_size = (450, 340) # (width, height)
print(f"New height and width: {new_size[1]}, {new_size[0]}")
resize_img = cv2.resize(img, new_size)

cv2.imshow('Original img', img)
cv2.imshow('Resized img', resize_img)

cv2.waitKey(0)

The program above will resize the input image and show original and resized images.

Actually, cv2.resize() has other functionalities. Please study more about this. It is interesting.

This is all for now. Hope you enjoy that.

By Asahi



Twitter is ending free access to their API

Starting February 9th, Twitter will no longer provide free access to the Twitter API and will begin a paid version.

In a series of tweets, a Twitter developer account said the company would stop supporting both the legacy v1.1 and the new v2 of his Twitter API. It wasn’t immediately clear how much they planned to charge for using the API.

https://twitter.com/TwitterDev/status/1621026986784337922

Following recent changes that caused Twitter to shut down third-party clients, many other app developers have become cautious about how to build on top of the Twitter API. This new move may force some developers to abandon their products or pass the costs on to their customers.

Thousands of developers use the Twitter API for dozens of purposes, including tracking changes between Twitter accounts and providing alerts. These are fun side projects for people who don’t want to pay fees for something they don’t monetize themselves.

Third-party companies were often the ones submitting new products and features for Twitter, and the social network did its part by not charging them for API usage. Under Musk, Twitter is striving to control how users around the world access the platform as it scales up its attempts to monetize the service.

Twitter has made its subscription service more expensive and changed the way tweets appear on a user’s timeline to make the platform more attractive, lucrative, and an attractive destination for a shrinking advertiser base.

Yuuma



Simple command line chat feature of netcat

Today, I would like to share about using netcat to send messages. Let’s take a look.

Netcat is a command line utility tool for performing operations about TCP or UDP and also known as a powerful networking tool. It is mostly used for port scanning, transfering data and troubleshooting a server but in this blog, I will share just about messaging using netcat.

You can install netcat by the following command in debian based operating systems. You will find other installation methods for other operating systems by googling.

sudo apt-get install netcat

To create a messaging service with netcat, run the following command in the terminal to listen on a port of the server.

// Ross

nc -lvp 2000

Ross’s terminal

And on the other system, run the following command to connect the chat server.

// Rachel

nc {ip_of_Ross} 2000

Rachel’s terminal

Now Ross and Rachel can send message to each other.

Ross’s terminal

Rachel’s terminal

But the messaging style is so simple that can’t know obviously who sent the message. For that, you can add prepending name to the chat by using mawk.

// Ross

mawk -W interactive '$0="Ross: "$0' | nc -l -v -p 2000

// Rachel

mawk -W interactive '$0="Rachel: "$0' | nc {ip_of_Ross} 2000

Ross’s terminal

Rachel’s terminal

There we go. It is cool, isn’t it.

For details of ‘nc’ usage, run ‘man nc’ in terminal.

This is all for now. Hope you enjoy that.

By Asahi



Flutterでフローティングアクションボタンについての変更する方法

1: 形状を変更する

FloatingActionButton( 
     shape: BeveledRectangleBorder(
          borderRadius: BorderRadius.zero
     ),
)

2:サイズを変更する

幅と高さは自由に調整できます。

SizedBox( 
    height:100,
    width:100,
    child:FloatingActionButton( 
       child: Icon(Icons.add), 
       onPressed: (){
            print("Button is pressed.");
        },
     ),
),

3:位置を変更する

場所を変更するには、ScaffoldのfloatingActionButtonLocationプロパティを使用します。

Scaffold(
    floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat
)

全部を纏めて、プロジェクトビルド した時

結果

return Scaffold(
        floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
        floatingActionButton: SizedBox(
          height: 100,
          width: 100,
          child: FloatingActionButton(
            child: Icon(Icons.add), 
            shape: BeveledRectangleBorder(borderRadius: BorderRadius.zero),
            onPressed: () {
              print("Button is pressed.");
            },
          ),
        ),
        backgroundColor: Colors.blue[100], 
        appBar: AppBar(
          title: Text("Floating Action Button"), 
          backgroundColor: Colors.redAccent, 
        ),
        body: Center(child: Text("Floating Action Button")));

金曜担当 – Ami



正規表現基礎(3)

今回はさまざまなプログラミング言語やツールで活用できる正規表現の記号を紹介します。
本記事は前回の「正規表現基礎(2)」の続きです。

続きを読む


アプリ関連ニュース

お問い合わせはこちら

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

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

お問い合わせフォーム