반응형

https://devjorgecastro.medium.com/modern-android-development-in-2024-b70f194938bd

 

Hello everyone 👋🏻, we are kicking off a new year, and I don’t want to miss this chance to share with you an article titled Modern Android Developmentin its 2024 version. 🚀

If you missed my previous article, you can take a look at Modern Android Development in 2023 and review the changes for this year

Disclaimer

📝 This article reflects my personal opinions and professional insights, considering diverse viewpoints within the Android developer community. Additionally, I regularly review the guidelines presented by Google for Android.

🚨 It is crucial to emphasize that while I may not explicitly mention certain compelling tools, patterns, and architectures, this omission does not negate their potential as valuable alternatives for developing Android applications.

Use Kotlin everywhere ❤️

Kotlin is a programming language developed by JetBrains. Recommended by Google who officially announced it in May 2017 (see publication here). It is a modern programming language that has compatibility with Java and can run on the JVM, which has made its adoption in the development of Android applications very fast.

Whether you are new to Android or not, you should consider Kotlin as your first choice, don’t swim against the tide 🏊🏻 😎, Google announced this approach at Google I/O 2019. With Kotlin, you will be able to use all the features of a modern language, including the power of Coroutines and the use of modern libraries developed for the Android ecosystem.

Official kotlin documentation here

Kotlin is a multipurpose language that we can use not only for developing Android applications, although much of its popularity has been due to the latter, as we can see in the following graph.

KotlinConf ‘23

Kotlin 2.0 is here

Another important thing to highlight is the release of Kotlin 2.0, which is just around the corner. As of the article’s date, it’s in its version 2.0.0-beta3

The new K2 compiler is also another addition in Kotlin 2.0, which will bring significant performance improvements, accelerate the development of new language features, unify all platforms supported by Kotlin, and provide a better architecture for multiplatform projects.

Check out the recap of KotlinConf ’23 where you can find more information.

Compose 🚀

Jetpack Compose is Android’s recommended modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.

 Jetpack Compose documentacion

Jetpack Compose is part of the Android Jetpack library and uses the Kotlin programming language to easily create a native user interface. Also, it integrates with other Android Jetpack libraries, such as LiveData and ViewModel, to make it easier to build reactive and maintainable Android applications.

Some key features of Jetpack Compose include:

  1. Declarative UI.
  2. Customizable widgets.
  3. Easy integration with existing code (old view system).
  4. Live preview.
  5. Improved performance.

Resources:

Android Jetpack ⚙️

Jetpack is a suite of libraries to help developers follow best practices, reduce boilerplate code, and write code that works consistently across Android versions and devices so that developers can focus on the code they care about.

_ Android Jetpack documentation

Some of its most common tools are:

Material You / Material Design 🥰

Material You, a new customization feature introduced in Android 12 and implemented within Material Design 3, empowers users to tailor the visual appearance of their operating system to align with their personal preferences. This innovative addition complements Material Design, an adaptable system of guidelines, components, and tools crafted to uphold the highest standards of user interface design. Supported by open-source code, Material Design fosters seamless collaboration between designers and developers, enabling teams to efficiently create stunning products.

Currently, the last version for Material Design is 3, you can see more here. Furthermore, you can take advantage of Material Theme Builder as assistance in defining your application’s theme.

 

Splash screens API

The SplashScreen API in Android is essential to ensure that applications display correctly on Android 12 and later versions. Not updating can impact the application launch experience. It is crucial to quickly adopt this API for a consistent user experience on the latest versions of the operating system.

 

Clean Architecture

The concept of Clean Architecture was introduced by Robert C. Martin. It is based on the separation of responsibilities through the division of software into layers.

Characteristics

  1. Independent of Frameworks.
  2. Testable.
  3. Independent of UI.
  4. Independent of Database.
  5. Independent of any external agency.

The Dependency Rule

The dependency rule is described very well by the author in his piece, The Clean Code Blog

The overriding rule that makes this architecture work is The Dependency Rule. This rule says that source code dependencies can only point inwards. Nothing in an inner circle can know anything at all about something in an outer circle. In particular, the name of something declared in an outer circle must not be mentioned by the code in the an inner circle. That includes, functions, classes. variables, or any other named software entity.

 The Clean Code Blog

Clean Architecture in Android

  • Presentation: Activities, Composables, Fragments, View Models and others view components.
  • Domain: Use Cases, Entities, Repositories, others domain components.
  • Data: Repository implementations, Mappers, DTO’s, etc.

Architecture Patterns for Presentation Layer

An architecture pattern is a higher-level strategy that aims to help design a software architecture and is characterized by being a solution within a reusable framework for common architectural problems. Architectural patterns are similar to design patterns, but they are larger in scale and address more global issues such as the overall structure of the system, the relationships between components, and the way that data is managed.

Within the Presentation layer, we have some architecture patterns, of which I would like to highlight the following:

  • MVVM
  • MVI

I do not want to go into explaining each one because on the internet you find too much information about this. 😅

In addition, you can also see the guide to app architecture

Image by developer.android.com
 

Dependency Injection

Dependency injection is a software design pattern that allows a client to obtain its dependencies from an external source rather than creating them itself. It is a technique for achieving Inversion of Control (IoC) between objects and their dependencies.

Modularization

Modularization is a software design technique that allows you to divide an application into independent modules, each with its own functionality and responsibility.

Image by developer.android.com

Benefits of modularization

Reusability: By having independent modules, they can be reused in different parts of the application or even in other applications.

Strict visibility control: Modules enable you to easily control what you expose to other parts of your codebase.

Customizable delivery: Play Feature Delivery uses the advanced capabilities of app bundles, allowing you to deliver certain features of your app conditionally or on demand.

Scalability: By having independent modules, functionalities can be added or removed without affecting other parts of the application.

Ease of maintenance: By dividing the application into independent modules, each with its own functionality and responsibility, it is easier to understand and maintain the code.

Ease of testing: By having independent modules, they can be tested in isolation, which makes it easy to detect and fix errors.

Architecture improvement: Modularizing helps to improve the architecture of the application, allowing a better organization and structure of the code.

Improve collaboration: By having independent modules, developers can work on different parts of the application simultaneously and without interference.

Build Time: Some Gradle functionalities such as incremental build, build cache or parallel build, can leverage modularity to improve build performance.

See more in the official documentation.

Network

Serialization

In this section I would like to mention two important tools in my opinion: Moshi widely used in conjunction with Retrofit and Kotlin Serialization, the Kotlin team’s bet at JetBrains.

Moshi and Kotlin Serialization are two serialization/deserialization libraries for Kotlin and Java that allow you to convert objects to JSON or another serialization format and vice versa. Both provide a user-friendly interface optimized for use in mobile and desktop applications. Moshi primarily focuses on JSON serialization, while Kotlin Serialization has support for various serialization formats, including JSON.

Image Loading

To load an image from the internet, there are several third-party libraries available to help you handle the process. Image loading libraries do a lot of the heavy lifting for you; they handle both caching (so you don’t download the image multiple times) and networking logic to download the image and display it on screen.

_ Official Android Documentation

Reactivity / Thread Management

When it comes to reactive programming and asynchronous processes, Kotlin Coroutines stand out with their Suspension Functions and Flow. However, it is crucial to acknowledge the value of RxJava in Android application development. Despite the growing adoption of Coroutines and Flow, RxJava remains a robust and popular choice in multiple projects.

For new projects always choose Kotlin Coroutines❤️. Explore some Kotlin Coroutines Concepts

 

Local Store

An important point when building mobile applications is having the ability to persist data locally, such as some session data or cache data, among others. It is important to choose the right storage option based on the needs of your application. We could store unstructured data like key-value or structured data like a database. Keep in mind that this point does not mention all the types of local storage that we have available (such as file storage), only the tools that allow us to save data.

Suggestions:

 

Testing 🕵🏼

Testing in software development is essential to ensure product quality. It detects errors, validates requirements, and ensures customer satisfaction. Below are some of the most commonly used tools for this purpose:

Testing section of the Tools documentation

Screenshot testing 📸

Screenshot testing in Android involves automatically capturing screenshots of various UI elements in an application and comparing them against baseline images to detect any unintended visual changes. It helps ensure consistent UI appearance across different versions and configurations of the app, catching visual regressions early in the development process.

 

R8 optimizations

R8 is the default compiler that converts your project’s Java bytecode into the DEX format that runs on the Android platform. It is a tool that helps us to obfuscate and reduce the code of our application by shortening the names of the classes and their properties, eliminating unused code and resources within the project. To see more, check the Android documentation about Shrink, obfuscate, and optimize your app. Additionally, you can also disable certain tasks or customize R8’s behavior through ProGuard rules files.

Image by androidtopics.dipien.com
  • Code shrinking
  • Resource shrinking
  • Obfuscation
  • Optimization

Third-party tools

  • DexGuard

Play Feature Delivery

Google Play’s app serving model, called Dynamic Delivery, uses Android App Bundles to generate and serve optimized APKs for each user’s device configuration, so users download only the code and resources they need to run your app.

 Android Documentation

Adaptive layouts

Image by android-developers.googleblog.com

With the growth in the use of mobile devices with different form factors, we need to have tools that allow us to work with our Android applications adapted to different types of screens. That is why Android provides us with Window Size Classes, which, in a simple way, are three large groups of screen formats that mark critical points for us to develop our designs. With this we avoid the complexity of thinking about many screen designs to reduce our possibilities to 3 groups which are: Compat, Medium and Expanded.

Windows Size Classes

Image by developer.android.com
Image by developer.android.com

Support different screen sizes

Another important resource that we have are the Canonical Layouts, which are predefined screen designs that can be used for most scenarios in our Android applications and also show us a guide on how to adapt them to large screens.

Other related resources

Form-Factor Training

Localization 🌎

Localization involves adapting a product to meet the needs of diverse audiences in different regions. This includes translating text, adjusting formats, and considering cultural aspects. Its advantages include access to global markets, enhanced user experience, increased customer satisfaction, competitiveness in the global market, and compliance with local regulations.

Note: BCP 47 is a standard used by Android for internationalization

References

Performance 🔋⚙️

Image by android-developers.googleblog.com

While we develop applications for Android, we must ensure that the user experience is better, not only at the beginning of the application but also throughout its execution. For this reason, it is important to have tools that allow us to carry out a preventive analysis and constant monitoring of cases that may affect the performance of the application, so here is a list of tools that will help you with this purpose:

In-App Updates

When your users keep your app up to date on their devices, they can try new features, as well as benefit from performance improvements and bug fixes. Although some users enable background updates when their device is connected to an unmetered connection, other users might need to be reminded to install updates. In-app updates is a Google Play Core libraries feature that prompts active users to update your app.

The in-app updates feature is supported on devices running Android 5.0 (API level 21) or higher. Additionally, in-app updates are only supported for Android mobile devices, Android tablets, and Chrome OS devices.

 In-App Updates documentation

Image by developer.android.com

In-App Reviews

The Google Play In-App Review API lets you prompt users to submit Play Store ratings and reviews without the inconvenience of leaving your app or game.

Generally, the in-app review flow can be triggered at any time throughout the user journey of your app. During the flow, the user has the ability to rate your app using the 1 to 5 star system and to add an optional comment. Once submitted, the review is sent to the Play Store and eventually displayed.

To protect user privacy and avoid API misuse, there are strict guidelines that your app should follow about when to request in-app reviews and the design of the review prompt.

 In-App Reviews documentation

Observability 👀

Image taken from Elastic Blog

In an increasingly competitive app ecosystem, achieving a good user experience begins with ensuring that the app is bug-free. One of the best ways to ensure that the app is bug-free is to immediately detect issues as they arise and know how to start addressing them. Use Android Vitals to identify the areas of your app that have the most crashes and issues with responsiveness. Then, utilize custom crash reports in Firebase Crashlytics to get more details about the root causes in order to troubleshoot the issues effectively.

Tools

Accessibility

Image by fscl01.fonpit.de

Accessibility is an important feature in the design and construction of software that provides the ability for people with accessibility needs to use the application, in addition to improving their user experience. Some disabilities that this concept aims to improve are: people with vision problems, color blindness, hearing problems, dexterity problems, and cognitive disabilities, among others.

Considerations:

  • Increase text visibility (Color contrast, Resizable Text)
  • Use large, simple controls
  • Describe each UI element

Check Accessibility — Android doc.

Security 🔐

Image by android.com

Security is one, if not the most important aspect, that we must take into account when developing applications that protect the integrity of the device, the security of the data, and the trust of the user, which is why I list below a series of tips that will help you with this purpose.

  • Sign in your user with Credential Manager: Credential Manager is a Jetpack API that supports multiple sign-in methods, such as username and password, passkeys, and federated sign-in solutions (such as Sign-in with Google) in a single API, thus simplifying the integration for developers.
  • Encrypt sensitive data and files: Use EncryptedSharedPreferences and EncryptedFile.
  • Apply signature-based permissions: Use signature-based permissions when sharing data between apps you have control over.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <permission android:name="my_custom_permission_name"
                android:protectionLevel="signature" />
  • Do not put keys, tokens, or sensitive data required for your application’s configuration directly inside files or classes that are inside the project repository. Use local.properties instead.
  • Implement SSL Pinning: Use SSL Pinning to further secure communications between your application and remote servers. This helps prevent man-in-the-middle attacks and ensures that communication only occurs with trusted servers possessing a specific SSL certificate.

res/xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config>
        <domain includeSubdomains="true">example.com</domain>
        <pin-set expiration="2018-01-01">
            <pin digest="SHA-256">ReplaceWithYourPin</pin>
            <!-- backup pin -->
            <pin digest="SHA-256">ReplaceWithYourPin</pin>
        </pin-set>
    </domain-config>
</network-security-config>
  • Implementa Runtime Application Self Protection (RASP): It is a security technique that protects applications at runtime against attacks and vulnerabilities. RASP works by monitoring the application’s behavior and detecting suspicious activities that could indicate an attack. some of the advantages that RASP provides us:

    - Code Obfuscation.
    - Root Detection.
    - Tampering/App Hook Detection.
    - Prevention of reverse engineering attacks.
    - Anti-Debugging Techniques.
    - Virtual Environment Detection.
    - Runtime Analysis of App Behavior.

Look at this article for more information: Runtime Application Self Protection techniques(RASP) in Android Apps. Also some Security guidelines by Android

Version Catalogs

Gradle provides a standard way to centrally manage project dependencies called the version catalog; it was experimentally introduced in version 7.0 and officially released in version 7.4.

Advantage:

  • For each catalog, Gradle generates type-safe accessors so that you can easily add dependencies with autocompletion in the IDE.
  • Each catalog is visible to all projects of a build. It is a central place to declare a version of a dependency and to make sure that a change to that version applies to every subproject.
  • Catalogs can declare dependency bundles, which are “groups of dependencies” that are commonly used together.
  • Catalogs can separate the group and name of a dependency from its actual version and use version references instead, making it possible to share a version declaration between multiple dependencies.

see more

Secrets Gradle Plugin

Google strongly recommends that you not check an API key into your version control system. Instead, you should store it in a local secrets.properties file, which is located in the root directory of your project but excluded from version control, and then use the Secrets Gradle Plugin for Android to read the API key.

Logger

A logger is a software tool used to register information about the execution of a program; important events, errors debug messages and other information that may be useful in diagnosing problems or understanding how a program is working. Loggers can be configured to write messages to different locations, such as a log file, to the console, to a database, or by sending the messages to a logging server.

Linter / Static Code Analyzer

Image taken from https://miro.medium.com/

Linter is a programming tool that is used to analyze the program source code to find potential problems or bugs in the code. These issues can be syntactic, inappropriate code style, lack of documentation, security issues, and so on, and they can have an impact on the quality and maintainability of the code.

Google Play Instant

Google Play Instant enables native apps and games to launch on devices running Android 5.0 (API level 21) or higher without being installed. You can build these types of experiences, called instant apps and instant games, using Android Studio. By allowing users to run an instant app or instant game, known as providing an instant experience, you improve your app or game’s discovery, which helps drive more active users or installations.

 Overview of Google Play Instant

 

New Design Hub

The Android team provides a new design hub to help create beautiful, modern Android apps, a centralized place to understand design for Android across multiple form factors.

d.android.com/design/ui

 

AI

Gemini and PalM 2, two state-of-the-art artificial intelligence (AI) models developed by Google, are poised to transform the landscape of Android application development. These models offer a range of benefits that will drive efficiency, user experience, and innovation in applications.

AI Coding Assistant Tools

Studio Bot

Studio Bot is your coding companion for Android development. It’s a conversational experience in Android Studio that helps you be more productive by answering Android development queries. It’s powered by artificial intelligence and can understand natural language, so you can ask development questions in plain English. Studio Bot can help Android developers generate code, find relevant resources, learn best practices, and save time.

 Studio Bot

Github Copilot

GitHub Copilot is an AI pair programmer. You can use GitHub Copilot to get suggestions for whole lines or entire functions right inside your editor.

Amazon CodeWhisperer

It is an Amazon service that generates code recommendations based on the context of your current code. It helps you write more efficient and secure code, and discover new APIs and tools.

 

Kotlin Multiplatform 🖥 📱⌚️ 🥰 🚀

Finally, and equally significant, the standout revelation of the year is Kotlin Multiplatform 🎉. It emerges as a formidable contender in the realm of cross-platform application development. While our primary focus may lie in Android app development, Kotlin Multiplatform offers us the flexibility to craft a fully native Android application leveraging the KMP framework. This strategic move not only future-proofs our projects but also equips us with the necessary infrastructure for a seamless transition to a multiplatform environment, should we choose to pursue it. 🚀

If you’re keen on delving deeper into Kotlin Multiplatform, I’d like to share a couple of articles I wrote a few months ago. In these pieces, I explore the current state of this technology and its implications for modern software development

반응형
반응형

 

지정 폴더안의 이미지 전부  텍스트 추출하기

# 파이썬 컴파일 경로가 달라서 현재 폴더의 이미지를 호출하지 못할때 작업디렉토리를 변경한다. 
import os
from pathlib import Path
# src 상위 폴더를 실행폴더로 지정하려고 한다.
###real_path = Path(__file__).parent.parent
real_path = Path(__file__).parent
print(real_path)
#작업 디렉토리 변경
os.chdir(real_path) 

"""_summary_
pip install pillow
pip install pytesseract



다운 받아야하는 학습된 한글 데이터 파일명: kor.traineddata
파일 위치: tesseract가 설치된 경로 C:\Program Files\Tesseract-OCR\tessdata

"""



from PIL import Image
import pytesseract  
import cv2 
import matplotlib.pyplot as plt

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
config = ('-l kor+eng --oem 3 --psm 11')
#config = ('-l kor+eng')
directory_base = str(real_path)+"./img/"  # 경로object를 문자열로 변경해서 합친다. 

        
# Open an image file
image_path = directory_base+"03_kor_eng.png"  # Replace with your image file path
img = Image.open(image_path)

# Use Tesseract to extract text
text = pytesseract.image_to_string(img, config=config)

print("Extracted Text:" + text)

image = cv2.imread(image_path)
rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

plt.imshow(rgb_image)

# use Tesseract to OCR the image 
# text = pytesseract.image_to_string(rgb_image, lang='kor+eng')
text = pytesseract.image_to_string(rgb_image, config=config)
print(text)


if __name__ == "__main__":
     
    # List all files in the directory
    file_list = [f for f in os.listdir(directory_base) if os.path.isfile(os.path.join(directory_base, f))]

    # Print the list of files
    for file in file_list:
        print(file)
        # Open an image file
        image_path = directory_base + file  # Replace with your image file path
        img = Image.open(image_path)

        text = pytesseract.image_to_string(img, config=config)
        print("Extracted Text:")
        print(text)

[python] 이미지에서 텍스트 추출하기,  tesseract, OCR

 

 

반응형
반응형

프리랜서를 위한 종합소득세 신고 Q&A


4월 말이면 푸릇푸릇해지는 바깥 풍경과 함께 국세청으로부터 어김없이 안내문이 도착합니다. 5월을 맞이하여 종합소득세를 신고하라는 그 안내문 말이죠. 환급에 대한 기대로 마음이 설레는 건 잠깐, 종합소득세 신고 절차는 매번 어렵게 느껴지기만 합니다. 혼자 일하는 1인 사업자, 프리랜서의 자부심으로 종합소득세 신고도 혼자 해보려고 하는데, 막막하기만 하신가요? 프리랜서를 위한 맞춤형 종합소득세 정보 및 신고 방법을 Q&A로 알려드립니다.


Q. 프리랜서는 왜 종합소득세를 신고해야 하나요?
프리랜서라면 3.3%라는 숫자가 익숙하실 겁니다. 업체로부터 비용을 받을 때 항상 3.3%를 떼고 받기 때문이죠. 그런데 이 3.3%의 금액이 소득세라는 것, 알고 계셨나요? 정확히 3%는 소득세, 0.3%는 지방 소득세입니다.
이렇게 미리 세금을 떼는 걸 원천징수라고 하는데요. 원천징수란 나중에 세금을 내는 번거로운 절차를 거치는 대신 회사 측에서 임의로 지정된 3.3%의 세금을 미리 내주는 것입니다.
그리고 5월이 되면 과연 내가 미리 낸 세금이 진짜 내가 냈어야 하는 세금과 얼마나 차이가 나는지를 확인하는 것이 종합소득세 신고 과정입니다. 내 지난 연도의 총 수입과 비용, 그에 따른 소득, 그리고 내 여러 상황 등을 감안하여 각종 공제 등을 적용하여 최종 세액을 산출하는데요. 이 최종 세액보다 미리 3.3%로 낸 세금이 많으면 그 금액을 돌려받는 것이고, 미리 낸 세금이 더 적으면 세금을 더 내는 것입니다.


Q. 정확히 무엇에 대한 세금인가요?
직전연도 1월 1일부터 12월 31일까지 번 돈에 관한 세금입니다. 2023년 5월이라면 2022년 한 해의 수입에 관한 세금을 신고하는 것이죠. 좀 더 구체적으로 말하자면 작년 한 해 동안의 총 수입에서 사업에 필요한 지출(비용)을 빼고 계산한 (실질적인) 소득에 관한 세금입니다. 따라서 내가 작년에 총 얼마의 수입을 벌어들였고, 또 일 때문에 지출한 돈은 얼마이며, 그리하여 실질적으로 얻은 소득은 얼마인지를 신고하는 것이 종합소득세 신고의 핵심입니다.


Q. 언제까지 해야 하나요?
종합소득세 신고는 딱 5월 동안입니다. 5월 1일부터 5월 31일 사이에 종합소득세 신고를 마쳐야 합니다. 이 기간을 놓친 후에도 신고는 가능하지만 가산세가 발생하게 됩니다.


Q. 혼자서 종합소득세를 신고할 수 있나요?
수입 규모가 크고 소득 종류가 다양한 프리랜서가 아니라면 혼자서도 종합소득세를 신고할 수 있습니다. 다만 작년 소득이 2400만원 이하라면 신고가 조금 더 간편하고, 2400만원을 초과했다면 필요한 절차가 더 추가될 수 있습니다.


Q. 종합소득세 신고, 무엇부터 해야 하나요?
첫째, 작년의 내 총 수입부터 파악해야 합니다. 홈택스에 들어가서 국세청에 등록되어 있는 내 작년 수입이 내가 알고 있는 금액과 일치하는지, 누락된 수입은 없는지 확인해 보세요.
둘째, 경비를 확인해야 합니다. 경비란 일 때문에 지출하게 된 비용을 말하는데요. 이 비용을 총 수입에서 빼야 내 소득이 나오고, 이 금액을 기준으로 세금이 매겨집니다. 프리랜서가 인정 받을 수 있는 경비는 보통 장비 구입비, 교통비, 경조사비, 교육비, 거래처 접대비, 도서구입비, 사무용품비, 통신비 등이 있는데요. 장부를 작성하고 관련 자료를 제출하여 이 비용들을 입증하는 방법이 있고, 장부 없이 국세청이 정한 경비율을 적용하여 한번에 비용을 처리하는 방법이 있습니다.
셋째, 이제 수입과 경비, 소득을 파악하고 그에 따른 종합소득세 신고 절차의 중요 개념을 알았으니 내 신고 유형을 확인할 때입니다. 국세청에서 보내준 안내문이나 홈택스에 들어가서 내 신고 유형을 확인해보세요. 신고 유형을 보면 나는 단순경비율과 기준경비율 중 어떤 항목을 적용 받는지, 간편장부와 복식부기 중 어떤 방식으로 장부를 써야 하는지 등을 알 수 있는데요. 그에 따라 세금 신고 전략을 세워야 합니다.


Q. 단순경비율과 기준경비율은 또 뭔가요?
원칙적으로는 세금을 신고할 때 내가 일 때문에 지출한 돈을 하나하나 증명하여 비용으로 처리해야 합니다. 하지만 소득이 적거나 이를 증명할 수 있는 장부를 쓰지 않은 경우, 전체 수입 중 일정 비율을 간단히 계산하여 그만큼을 경비로 썼다고 추산해주는데요. 이 비율을 경비율이라고 합니다. 말 그대로 경비로 인정해주는 비율이죠. 경비율은 업종마다 세세하게 국세청이 그 비율을 다르게 정해놓아서 직접 확인해야 합니다.
경비율에는 단순경비율과 기준경비율 두 가지가 있습니다. 우선 단순경비율은 수입이 낮은 사람들에게 적용되며 비율이 비교적 높아 비용으로 처리할 수 있는 금액이 높아집니다. 그에 따라 실질 소득이 낮게 잡혀 세금도 낮아지죠. 단순경비율 대상자인 프리랜서라면 종합소득세를 혼자 신고하는 게 충분히 가능합니다.
반면 기준경비율은 비율 자체도 낮고 경비 항목 중 일부(기타 경비)에 대해서만 적용됩니다. 기준경비율 대상자는 매입비, 임차료, 인건비를 지출했더라도 이를 따로 입증해야만 이 비용을 경비로 뺄 수 있습니다. 더구나 사업자를 내지 않은 프리랜서의 경우 기준경비율 대상자라면 애초에 경비로 적용되는 금액도 적고, 매입비, 임차료, 인건비는 지출할 일이 잘 없어 경비로 뺄 수 있는 금액이 적은 경우가 대다수인데요. 이럴 경우 경비율을 적용하지 않고 장부로 직접 비용을 증명하여 경비를 인정받는 것이 유리할 때가 많으며, 이를 위해 세무 대리 서비스를 사용하는 게 더 이득일 수 있습니다.


Q. 주요 개념들을 알았으니 혼자 해볼게요. 어떻게 하면 되죠?
홈택스에 접속하여 [신고/납부] → [종합소득세] → [모두채움 신고/단순경비율 신고] 또는 [일반 신고]로 들어가면 종합소득세 신고가 시작됩니다. 차례차례 나오는 페이지를 따라 내 정보를 입력하고, 수입을 확인하고, 비용을 장부 또는 경비율로 처리하고, 적용 가능한 공제 또는 감면 혜택이 있는지 확인하고, 최종 산출 세액을 확인해보세요.
추가로 홈택스에서는 쉽게 종합소득세를 신고할 수 있도록 여러 서비스를 지원하고 있습니다. 특히 사업소득 원천징수가 이루어진 프리랜서 중 소득금액이 2400만원 이하일 경우 환급안내까지 해주는 납세자 친화형 서비스를 새롭게 시작하고 있으니 참고하세요.


Q. 세무 대리를 고민 중이에요. 괜찮을까요?
만약 신고 안내문에서 확인한 내 신고 유형이 기준경비율 대상자라면 세무 대리를 하는 것이 이득일 수 있습니다. 기준경비율 대상자는 경비율을 적용하는 것보다 장부를 제출하여 세금을 신고하는 것이 이득일 가능성이 높기 때문인데요. 장부 제출 시 간편장부라는 비교적 쉬운 장부를 쓰라고 국세청에서 정해줬더라도 비전문가에다 바쁜 프리랜서라면 그마저 쉽지 않습니다. 간편장부보다 더 어려운 복식부기를 써야 할 때는 물론이고, 장부를 쓰는 일부터 시작해 내게 가장 이득이 되는 절세 전략을 세워 세금을 찾아주는 세무사를 구해 신고를 마치는 게 더 현명한 판단일 수 있습니다.

반응형
반응형

pip install pytesseract

 

한글팩 : https://github.com/tesseract-ocr/tessdata/

 
다운 받아야하는 학습된 한글 데이터 파일명: kor.traineddata
파일 위치: tesseract가 설치된 경로 C:\Program Files\Tesseract-OCR\tessdata
 

*** 설치 할때 언어팩 선택 

 

pytesseract 0.3.10

 

Python-tesseract is an optical character recognition (OCR) tool for python. That is, it will recognize and “read” the text embedded in images.

Python-tesseract is a wrapper for Google’s Tesseract-OCR Engine. It is also useful as a stand-alone invocation script to tesseract, as it can read all image types supported by the Pillow and Leptonica imaging libraries, including jpeg, png, gif, bmp, tiff, and others. Additionally, if used as a script, Python-tesseract will print the recognized text instead of writing it to a file.

USAGE

Quickstart

Note: Test images are located in the tests/data folder of the Git repo.

Library usage:

from PIL import Image

import pytesseract

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
# Example tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract'

# Simple image to string
print(pytesseract.image_to_string(Image.open('test.png')))

# In order to bypass the image conversions of pytesseract, just use relative or absolute image path
# NOTE: In this case you should provide tesseract supported images or tesseract will return error
print(pytesseract.image_to_string('test.png'))

# List of available languages
print(pytesseract.get_languages(config=''))

# French text image to string
print(pytesseract.image_to_string(Image.open('test-european.jpg'), lang='fra'))

# Batch processing with a single file containing the list of multiple image file paths
print(pytesseract.image_to_string('images.txt'))

# Timeout/terminate the tesseract job after a period of time
try:
    print(pytesseract.image_to_string('test.jpg', timeout=2)) # Timeout after 2 seconds
    print(pytesseract.image_to_string('test.jpg', timeout=0.5)) # Timeout after half a second
except RuntimeError as timeout_error:
    # Tesseract processing is terminated
    pass

# Get bounding box estimates
print(pytesseract.image_to_boxes(Image.open('test.png')))

# Get verbose data including boxes, confidences, line and page numbers
print(pytesseract.image_to_data(Image.open('test.png')))

# Get information about orientation and script detection
print(pytesseract.image_to_osd(Image.open('test.png')))

# Get a searchable PDF
pdf = pytesseract.image_to_pdf_or_hocr('test.png', extension='pdf')
with open('test.pdf', 'w+b') as f:
    f.write(pdf) # pdf type is bytes by default

# Get HOCR output
hocr = pytesseract.image_to_pdf_or_hocr('test.png', extension='hocr')

# Get ALTO XML output
xml = pytesseract.image_to_alto_xml('test.png')

Support for OpenCV image/NumPy array objects

import cv2

img_cv = cv2.imread(r'/<path_to_image>/digits.png')

# By default OpenCV stores images in BGR format and since pytesseract assumes RGB format,
# we need to convert from BGR to RGB format/mode:
img_rgb = cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB)
print(pytesseract.image_to_string(img_rgb))
# OR
img_rgb = Image.frombytes('RGB', img_cv.shape[:2], img_cv, 'raw', 'BGR', 0, 0)
print(pytesseract.image_to_string(img_rgb))

If you need custom configuration like oem/psm, use the config keyword.

# Example of adding any additional options
custom_oem_psm_config = r'--oem 3 --psm 6'
pytesseract.image_to_string(image, config=custom_oem_psm_config)

# Example of using pre-defined tesseract config file with options
cfg_filename = 'words'
pytesseract.run_and_get_output(image, extension='txt', config=cfg_filename)

Add the following config, if you have tessdata error like: “Error opening data file…”

# Example config: r'--tessdata-dir "C:\Program Files (x86)\Tesseract-OCR\tessdata"'
# It's important to add double quotes around the dir path.
tessdata_dir_config = r'--tessdata-dir "<replace_with_your_tessdata_dir_path>"'
pytesseract.image_to_string(image, lang='chi_sim', config=tessdata_dir_config)

Functions

  • get_languages Returns all currently supported languages by Tesseract OCR.
  • get_tesseract_version Returns the Tesseract version installed in the system.
  • image_to_string Returns unmodified output as string from Tesseract OCR processing
  • image_to_boxes Returns result containing recognized characters and their box boundaries
  • image_to_data Returns result containing box boundaries, confidences, and other information. Requires Tesseract 3.05+. For more information, please check the Tesseract TSV documentation
  • image_to_osd Returns result containing information about orientation and script detection.
  • image_to_alto_xml Returns result in the form of Tesseract’s ALTO XML format.
  • run_and_get_output Returns the raw output from Tesseract OCR. Gives a bit more control over the parameters that are sent to tesseract.

Parameters

image_to_data(image, lang=None, config='', nice=0, output_type=Output.STRING, timeout=0, pandas_config=None)

  • image Object or String - PIL Image/NumPy array or file path of the image to be processed by Tesseract. If you pass object instead of file path, pytesseract will implicitly convert the image to RGB mode.
  • lang String - Tesseract language code string. Defaults to eng if not specified! Example for multiple languages: lang='eng+fra'
  • config String - Any additional custom configuration flags that are not available via the pytesseract function. For example: config='--psm 6'
  • nice Integer - modifies the processor priority for the Tesseract run. Not supported on Windows. Nice adjusts the niceness of unix-like processes.
  • output_type Class attribute - specifies the type of the output, defaults to string. For the full list of all supported types, please check the definition of pytesseract.Output class.
  • timeout Integer or Float - duration in seconds for the OCR processing, after which, pytesseract will terminate and raise RuntimeError.
  • pandas_config Dict - only for the Output.DATAFRAME type. Dictionary with custom arguments for pandas.read_csv. Allows you to customize the output of image_to_data.

CLI usage:

pytesseract [-l lang] image_file

INSTALLATION

Prerequisites:

  • Python-tesseract requires Python 3.6+
  • You will need the Python Imaging Library (PIL) (or the Pillow fork). Under Debian/Ubuntu, this is the package python-imaging or python3-imaging.
  • Install Google Tesseract OCR (additional info how to install the engine on Linux, Mac OSX and Windows). You must be able to invoke the tesseract command as tesseract. If this isn’t the case, for example because tesseract isn’t in your PATH, you will have to change the “tesseract_cmd” variable pytesseract.pytesseract.tesseract_cmd. Under Debian/Ubuntu you can use the package tesseract-ocr. For Mac OS users. please install homebrew package tesseract.
  • Note: In some rare cases, you might need to additionally install tessconfigs and configs from tesseract-ocr/tessconfigs if the OS specific package doesn’t include them.
Installing via pip:

Check the pytesseract package page for more information.

pip install pytesseract
Or if you have git installed:
pip install -U git+https://github.com/madmaze/pytesseract.git
Installing from source:
git clone https://github.com/madmaze/pytesseract.git
cd pytesseract && pip install -U .
Install with conda (via conda-forge):
conda install -c conda-forge pytesseract

TESTING

To run this project’s test suite, install and run tox. Ensure that you have tesseract installed and in your PATH.

pip install tox
tox

반응형
반응형

 

 

https://www.theverge.com/2024/1/29/24055011/meta-llama2-code-generator-generative-ai

 

삽화: Alex Castro / The Verge

코드 생성 AI 모델인 Code Llama 70B 에 대한 Meta의 최신 업데이트는 아직까지 "가장 크고 성능이 뛰어난 모델"입니다. Code Llama 도구는 8월에 출시되었으며 연구 및 상업용 모두 무료입니다. Meta의 AI 블로그 게시물에 따르면 Code Llama 70B는 이전 버전보다 더 많은 쿼리를 처리할 수 있습니다. 이는 개발자가 프로그래밍하는 동안 더 많은 프롬프트를 제공할 수 있고 더 정확할 수 있음을 의미합니다.

Code Llama 70B는 HumanEval 벤치마크에서 정확도 53%를 기록하여 GPT-3.5의 48.1%보다 나은 성능을 보였고 GPT-4에 대해 보고된 OpenAI 문서 (PDF) 의 67%에 더 가깝습니다 .

 

Llama 2를 기반으로 구축된 Code Llama는 개발자가 프롬프트에서 코드 문자열을 생성하고 사람이 작성한 작업을 디버깅하는 데 도움이 됩니다. Meta는 지난 가을에 특정 코딩 언어에 초점을 맞춘 두 가지 다른 Code Llama 도구인 Code Llama - Python과 Code Llama - Instruct를 동시에 출시했습니다.

Code Llama 70B는 세 가지 버전의 코드 생성기에서 사용할 수 있으며 연구 및 상업적 용도로는 여전히 무료입니다. 대규모 모델은 1TB의 코드 및 코드 관련 데이터에 대해 학습되었습니다. AI 모델을 실행하기 위해 GPU에 대한 액세스를 제공하는 코드 저장소 Hugging Face에서 호스팅됩니다.

Meta는 자사의 대형 모델인 34B 및 70B가 "최고의 결과를 반환하고 더 나은 코딩 지원을 제공합니다"라고 말했습니다.

다른 AI 개발자들은 작년에 코드 생성기를 출시했습니다. Amazon의 CodeWhisperer는 4월에 출시되었으며 Microsoft는 OpenAI의 모델을 활용하여 GitHub Copilot을 출시했습니다 

반응형
반응형

비전 프로 출시 D-2

Vision Pro Review: 24 Hours With Apple’s Mixed-Reality Headset | WSJ

 

https://www.youtube.com/watch?v=8xI10SFgzQ8

실리콘밸리 시간으로는 3일, 한국시간으로는 2일 후 애플의 신형 디바이스인 비전 프로가 판매를 드디어 시작하는데요. 미국의 미디어 유튜버들의 제품 리뷰와 영상이 본격적으로 공개되기 시작했어요. 유튜브나 뉴스검색을 통해서 찾아보실 수 있는데요. 리뷰어들의 소감 중에서 재미있는 것을 정리해봤어요. 

 

  • 무겁다 : 실제 무게도 있지만 메타 퀘스트와 달리 무게가 앞에 쏠려있는 점이 문제.
  • 가상 키보드는 별로 : 비전 프로로 일을 하고 싶다면 실물 키보드를 추천.
  • 안경은 못쓴다 : 안경을 쓰고 착용하기 어렵기 때문에 도수가 있는 렌즈를 별도로 구매해서 부착해야해요.  
  • 놀라운 디스플레이 : 디스플레이 성능이 너무 좋은데 이것이 높은 가격의 가장 큰 원인 중 하나. 
  • 패스스루도 완벽 : 비전 프로를 착용해도 카메라를 통해서 외부를 보는 혼합현실(Mixed Reality)기능이 매우 훌륭하다고 해요. 
  • 시리를 많이 사용하게 된다 : 음성 AI 비서인 시리가 비전프로에서도 당연히 작동을 하는데, 비전프로를 쓰고 있는 환경에서는 자연스럽게 시리를 호출해서 명령을 내리는 경우가 많아요. 마치 아이언맨이 자비스를 부르는 것 처럼요.  
  • 3D 영상 촬영이 킬러 서비스 : 아이폰15 프로로 공간동영상(Spatial)을 촬영할 수 있는데, 이걸 비전 프로에서 볼 수 있어요. 많은 리뷰어들이 여기에 만족을 나타냈어요. 2D 영상을 보는 것보다 과거의 경험을 다시 생생하게 느낄 수 있다고 해요. 특히 아이의 영상을 찍은 부모들의 만족도가 높았어요. 과거 캠코더가 아이들의 영상을 찍기 위해 많은 부모들이 샀던 것처럼 비전 프로 수요도 있을 것 같아요.  
  • 침대에 누워서 쓰기 좋다 : 침대에서 스마트폰을 쓰는 분들이 많은데, 비전 프로를 쓰면 무게도 덜 느끼고 좋을 것 같아요.

패스스루란?

패스스루는 VR 화면에서 벗어나 주변의 실제 환경을 볼 수 있게 해주는 기능입니다. 패스스루는 헤드셋의 센서를 사용하여 사용자가 헤드셋 너머의 실제 환경을 본다고 가정했을 때 보게 될 환경을 대략적으로 보여줍니다. 안전 보호 경계를 만들거나 조정할 때 자동으로 패스스루가 작동합니다. 실제 및 가상 환경을 혼합하기 위해 앱에도 패스스루가 표시됩니다.

반응형
반응형

우선 사용자가 페이지 안에서 스크롤을 사용해 이동하는 경우 어떤 방법을 사용할까요?

1.마우스의 휠 버튼을 사용하는 경우
2.키보드의 커서키를 사용하는 방법
3.스크롤 바 위에 마우스를 올려 드래그하여 이동하는 방법


이처럼 세가지 방법이 가장 보편적입니다. 이 중에서 오늘은 스크롤을 사용한 이동시 이를 블락하는 방법을 알아보겠습니다. 먼저 스크롤을 막는 것이 왜? 그리고 언제 필요할까요?

# 스크롤의 이동을 막는 것이 필요한 경우
언제 스크롤을 사용한 페이지 이동을 막아야할까요? 먼저 중요한 콘텐츠 화면 영역에서 빠른 스크롤 이동에 의하여 의도한 콘텐츠를 다 못보여주는 경우도 생각해볼 수 있습니다. 이런 경우는 예를 들면... 페이지 스크롤에 따라 화면이 동적으로 변하는 웹사이트의 경우가 이에 해당합니다. 동적으로 변하는 웹사이트를 보여주기 위해 사용자의 스크롤 이동을 강제하는 것이 필요할 수 있습니다.

또 다른 이유로 스크롤이 화면에 고정되야 하는 경우입니다. 햄버거 버튼을 누른 뒤거나 아니면 모달 형식의 팝업창을 띄운 경우가 좋은 예 입니다.



# 스크롤을 고정하는 방법 예제 소스보기
아래의 소스 코드를 봐주세요. 이코드는 스크립트와 CSS를 사용하여 사용자의 페이지 이동을 강제적으로 막고 있습니다. 우선 스크롤이 생기지 않게 하기 위하여 html과 body 태그에 overflow 속성을 사용하였고 그 값으로 hidden을 주었습니다.

또한 해당하는 요소의 브라우저 기본 이벤트를 피하기 위해 아래의 이벤트 함수를 사용합니다. preventDefault()는 이벤트 내장함수의 실행을 막아 의도한 동작만을 방문자에게 보여줍니다. 또한 발생 가능한 아벤트 버블링을 피하기 위해 stopPropagation()을 추가하였습니다. 해당 자바스크립트는 아래와 같이 사용합니다.
event.preventDefault();
event.stopPropagation();

아래 코드를 직접 실행해 보면서 익혀보시기 바랍니다. 코드는 제이쿼리(jQuery)를 사용하여 만든 예제소스입니다.
$('html, body').css({'overflow': 'hidden', 'height': '100%'});
$('#element').on('scroll touchmove mousewheel', function(event) {
  event.preventDefault();
  event.stopPropagation();
  return false;
});

위 코드는 스크롤과 터치이동, 마우스휠의 이벤트 발생시 동작하지 않도록 제거합니다. 각각 scrolll, touchmove, mousewheel 이벤트 코드가 추가되어 있습니다.


# 스크롤 이동을 다시 허용하기
만약 다시 스크롤을 허용해야한다면? 이 경우 기존의 마우스 스크롤이벤트의 핸들러를 제거해야하므로 해제방법이 필요할 것입니다. 이때는 등록된 이벤트를 해제하여 주는 off() 메소드를 사용하여 가능합니다. 아래 코드의 예제를 봐주세요.
$('#element').off('scroll touchmove mousewheel');

여기까지 스크롤의 사용자 화면전환을 강제로 막는 방법을 알아보았습니다.



http://relation.co.kr/images_board/board_system_publishing/211/index.php/

반응형
반응형

R&R을 뛰어 넘어라

 

기업이 커지면 커질수록 분란의 싹이 함께 커집니다. 스타트업일 때는 동료들이 이일 저일 미루지 않고 함께 하지만, 조직이 커지면 위계질서가 만들어지고, 역할 분장이 명료해집니다. 드디어 직원들에겐 R&R(Role & Responsibility)이 부여됩니다. "이것은 네 일, 저것은 내 일" 하지만 기업은 늘 신사업을 찾다보니 갈등이 벌어집니다. 리더가 R&R을 매번 바꿔 줘야 하지만, 현실은 그렇지 못하니까요. 예를 들어,

 

  • 👩옆 팀장: 좀 도와줄 수 있나요? 우리 팀에서 새 업무를 아는 사람이 없는데
  • 🤫: 할 수 있을 것 같은데요. 일단 저희 팀장께 물어보고 답변 드릴게요.
  • 👦내 팀장: 책임님이 옆 팀 일을 거드시면 저희 팀 업무는 언제 하시려고요.
  • 😟: (어떻게 해야하지...ㅠㅠ)

 

R&R  

이러한 R&R을 도입한 것은 1920년대 제너럴 일렉트릭(GE)으로 알려졌어요. 당시 CEO인 앨프레드 P. 슬로언이 조직 개편을 주도하면서 각 부서와 직위에 따른 R&R을 정립했습니다. 업무 범위를 명확히 하고, 책임 한계를 설정했어요. 당시에는 파격이었습니다. 부서장이 내리는 업무외적 불필요한 명령을 차단하고, 회사 존립 목적 자체에 집중하도록 했기 때문인데요.

 

하지만 오늘날처럼 산업이 역동적으로 바뀌는 때에는 적합하지 않다는 지적이 있습니다. 그러다 보니 일 잘 하는 사람, 말 못하는 사람들이 여러 일을 떠안기 일쑤입니다. 회사에서 업무를 정의하면 크게 두 가지입니다. E&E!

 

E&E!

우선 Exploitation 활용은 품질과 프로세스 개선 등을 빠르고 효율적으로 하는 것을 가리킵니다. 반면 Exploration 탐험은 새로운 가능성에 대한 탐구입니다.

 

Exploitation이 현재 업무를 개선하고 나아가는 것이라면, Exploration은 신 사업을 찾아 떠나는 여정입니다. 오늘날은 이를 어떻게 조화롭게 구성할지가 관건인데요. 몇몇 기업들은 이를 비율로 만들어 둡니다.

 

구글: 20% 타임제

구글은 직원이 여유 시간이 있어야 Exploration이 가능하다고 판단해요. 그래서 20% 타임제를 두고 있습니다. (물론 120% 야근제 아니냐는 지적도...) 구글은 80%는 본업을 하고, 20%, 즉 일주일에 하루 정도는 현재 수행하고 있는 업무와 전혀 관련이 없는 활동을 하도록 장려합니다. 그 결과 구글 뉴스, 애드센스 포 콘텐츠, 구글 서제스트 등이 태어났습니다.

 

3M: 15%

스카치 테이프로 유명한 3M 역시 15%룰을 운영합니다. 일부 부서에 국한된 이야기이긴 한데요. 연구 조직은 자신의 업무 시간 중 15%를 업무와 무관한 프로젝트에 사용할 수 있습니다. 또 프로젝트가 실패하더라도, 책임이나 이유를 따지지 않습니다. 그 결과, 우리가 흔히 쓰는 포스트-잇이 태어났어요.

 

🔎크게보기

R&R을 놓고 선배들과 후배들 간 견해차이가 큽니다. 선배들은 그렇게 업무를 명확히 구분하면, 어떻게 회사가 굴러가느냐고 하지만, 후배들은 명확하지 않다면, 공정하지 않다고 여깁니다. 개인적으로는 조직이 크면 클수록 업무가 명확한 게 좋다고 생각합니다. 그렇지 않으면, 인재들이 불만을 품기 때문인데요.

 

하지만 조직이 경직화되는 것은 경계해야합니다. 꽉 막힌 조직은 더디게 성장하기 때문입니다. 중요한 것은 조직 전체가 어떻게 하면, 효율적으로, 창의적으로, 꿈틀대게 할지 다 같이 고민할 수 있는 공동체 정신 아닐까 합니다.

 

https://stibee.com/api/v1.0/emails/share/EkB2Zdv2mId7G7lF066P6JmtpdRFblA

반응형

+ Recent posts