Notes, summaries, assignments, exams, and exercises for Computer science for University

Image Processing in C with OpenCV: Loading and Swapping Image Halves

Computer science3.85 KB

Image Processing in C with OpenCV

#include <stdio.h>
#include <stdlib.h>


#include <opencv/cv.h>
#include <opencv/highgui.h>


int main(int argc, char **argv)
{
if (argc != 2)
{
printf("Error: Usage %s image_file_name\n", argv[0]);
return EXIT_FAILURE;
}


//CV_LOAD_IMAGE_COLOR = 1 forces the resultant IplImage to be colour.
//CV_LOAD_IMAGE_GRAYSCALE = 0 forces a greyscale IplImage.
//CV_LOAD_IMAGE_UNCHANGED = -1
IplImage* Img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);


// Always check if the program can find the image file
if (!Img)
{
printf("Error: file %s not found\n", argv[1]);
return EXIT_FAILURE;
}


// a visualization window is created with title: image file
...
Continue reading "Image Processing in C with OpenCV: Loading and Swapping Image Halves" »

SQL Database Exercise: Clients, Carriers and Orders Queries

Computer science2.63 KB

SQL Database Exercise: Clients, Carriers and Orders

CREATE DATABASE EX4_1;

USE EX4_1;

Creating the clients table

CREATE TABLE clientes
(codcli INT,
nome VARCHAR(30),
endereço VARCHAR(40),
cidade VARCHAR(30),
fone CHAR(9),
CONSTRAINT pk_clientes PRIMARY KEY(codcli));

INSERT INTO clientes VALUES
(1,'Elevanir','Rua do Parque','Mauá','945653285'),
(2,'Lucas','Rua do Iorgute','Mauá','954658545'),
(3,'Ludirbe','Rua da Vadiagem','Santo André','954785452'),
(4,'Lairdison','Rua do Fermento','São Bernardo do Campo','954658532'),
(5,'Leandro','Rua do Bolo','Norte','954658545');

Creating the carriers table

CREATE TABLE transportadora
(codigo INT,
nome VARCHAR(20),
CONSTRAINT pk_transportadora PRIMARY KEY(codigo));

INSERT INTO transportadora VALUES
(1,'Fedex'),
(2,'Polar...

Continue reading "SQL Database Exercise: Clients, Carriers and Orders Queries" »

Android Mobile Application Development Essentials

Computer science16.66 KB

CSC525 Wireless and Mobile Computing

Mobile Devices: The Good

  • Always-on person
  • More than one means of connection
  • Applications are free or low cost
  • Has many sensors: accelerometer, GPS
  • Increasing in capability at an alarming rate

Mobile Devices: The Bad

  • Battery life
  • Unreliable, costly, and high-latency network access
  • Screen size
  • Different platforms across and even within device families
  • Input
  • Processor
  • Storage

How do you think you can compensate for these shortcomings?

Why Android?

  • Popularity
  • Feature set
  • Flexibility
  • No license fee
  • Powerful SDK
  • Documentation and developer community
  • Android market
  • No approval process
  • Ease of distribution and monetizing

Native vs. Web Applications

What are the pros and cons?

Types of Applications

  • Foreground: Typically only useful when visible
...
Continue reading "Android Mobile Application Development Essentials" »

Core Principles of Object-Oriented Programming

Computer science921 bytes

Abstraction

  • Application Analysis: The class or object model extracts the essential features of a real-world class or object.
  • Software Design: The public interface supports a simple logical model, while implementation complexity remains hidden from the client view.

Modularity

  • Application Analysis: Objects provide a more expressive and fine-grained structuring capability than decomposition by processing activity alone.
  • Software Design: Objects are information clusters that can be declared as often and wherever needed.

Encapsulation

  • Classes build “firewalls” around objects, forcing all access through public interfaces and preventing access to private implementation.
  • Objects intercept errors before they propagate outward throughout the system.

Implementando 4x4 Matriz Transposta em Linguagem C

Computer science2.66 KB

Implementação da Transposição de Matriz 4x4 em C

Este programa em C demonstra como calcular e exibir a matriz transposta (B) de uma matriz quadrada de ordem 4 (A). A transposição é realizada trocando as linhas pelas colunas, ou seja, o elemento na posição A[i][j] é copiado para B[j][i].

Código Fonte em C para Transposição de Matriz

O código utiliza as bibliotecas padrão stdio.h para entrada/saída e conio.h (comum em ambientes legados) para controle de console.

#include <stdio.h>
#include <conio.h>

int main()
{
    int i, j, A[4][4], B[4][4];

    // 1. Entrada de Dados
    printf("Insira os elementos da Matriz A (4x4):\n");
    for(i = 0; i < 4; i++)
    {
        for(j = 0; j < 4; j++)
        {
            printf(
...
Continue reading "Implementando 4x4 Matriz Transposta em Linguagem C" »

Fundamentals of Data Processing and Information Systems

Computer science2.6 KB

Understanding Data and Information

A figure is a symbolic representation (numerical, alphabetical, algorithmic, etc.) and an attribute or characteristic of an entity.

Difference Between Data and Information

Data differs from information; various methods are used to compress information to allow for more efficient transmission or storage.

The amount of information in a message can be understood as the number of possible symbols representing the message. Symbols representing the message are considered meaningful data.

The Data Processing Cycle

Data Processing involves careful and systematic procedures performed to develop, codify, and organize data for analysis.

Four Key Data Processing Steps

  1. Data Capture: This involves making an observation in order
...
Continue reading "Fundamentals of Data Processing and Information Systems" »

Software Architecture Design: UML Concepts & Layered Systems

Computer science2.54 KB

Software Architecture Design Principles

Key aspects of software design include:

  • Software Architecture Design: Defines the major structural components of the software and their relationships.
  • Project Data Design: Involves designing the data structure needed to implement the software.
  • Procedural Design: Refines and details the procedural description of the structural components defined in the software architecture.
  • Interface Design: Describes how software communicates internally (internal interfaces), with other systems (external interfaces), and with users (user interface).

Component vs. Class Diagrams in UML

Similarities

  • Both can realize a set of interfaces.
  • Both can participate in various relationships (dependency, generalization, association).
  • Both
...
Continue reading "Software Architecture Design: UML Concepts & Layered Systems" »

Network Switches vs. Hubs: Performance and VLAN Benefits

Computer science2.49 KB

Network Switches vs. Hubs: Key Differences

A network switch offers significantly higher performance than a hub. Below are the primary distinctions:

Hub Characteristics

  • Bandwidth: Shared bandwidth (e.g., 10Mbps shared among 5 devices results in 2Mbps per device).
  • Transmission: Cannot handle simultaneous transmissions to multiple devices at once.
  • Cost: Generally cheaper than a switch.

Switch Characteristics

  • Bandwidth: Each device receives the total available bandwidth.
  • Performance: Supports multiple simultaneous data transmissions.
  • Bridge Comparison: Unlike a bridge, a switch operates using the same protocols at the physical and link layers, offering superior speed and performance.

Virtual Local Area Networks (VLANs)

Traditional LANs are highly dependent...

Continue reading "Network Switches vs. Hubs: Performance and VLAN Benefits" »

Data Segmentation and Port Management in TCP/IP

Computer science3.25 KB

Functions of the Transport Layer

The Transport Layer allows the segmentation of data and provides the control necessary to reassemble the parts into different streams of communication. The main responsibilities to be met include:

  • Tracking individual communication between applications on hosts of origin and destination.
  • Data segmentation and the handling and management of each segment in application data streams.
  • Identification of different applications.

Data Segmentation and Encapsulation

The protocols of the Transport Layer describe the services that segment the application layer data. This includes the necessary encapsulation of data in each section. Each section of the application requires data to be added to headers in the Transport Layer to...

Continue reading "Data Segmentation and Port Management in TCP/IP" »

Visual Basic Student Management System: Code Walkthrough and Fixes

Computer science5.36 KB

Student Management Form in Visual Basic

The following code implements a student records form in Visual Basic, including navigation between forms, database operations, and a password login.

Closing the Form

Private Sub btncerrar_Click()
    c = MsgBox("Do you really want to quit?", vbYesNo, "Close")
    If c = vbYes Then
        frmmenuprincipal.Show
        frmestudiantes.Hide
    End If
End Sub

Creating a New Record

Private Sub btnnuevo_Click()
    Call New
End Sub

Private Sub New()
    Data1.Recordset.AddNew
    Call habilitarcajas
    btnnuevo.Enabled = False
    btnguardar.Enabled = True
    btnbuscar.Enabled = True
    btneliminar.Enabled = True
    btncerrar.Enabled = True
    mnunuevo.Enabled...

Continue reading "Visual Basic Student Management System: Code Walkthrough and Fixes" »