오렌지파이 제로를 이용하기 위해서는 이더넷을 연결해야만 편하게 쓸 수 있는데, 사실 와이파이가 있는 요즘 세상에 이더넷 연결하기란 여간 귀찮은 일이 아니다. 따라서 와이파이 설정을 하여 인터넷을 사용해보도록 한다.

1. interfaces 변경

  • cd 명령어를 통해 /etc/network로 들어간다.
    • cd /etc/network
  • nano를 사용하여 interfaces 내용을 다음과 같이 변경한다.

interfaces 내용을 수정하는 과정

2. wpa_supplicant.conf 변경

  • cd 명령어를 통해 /etc/wpa_supplicant로 들어간다
    • cd /etc/wpa_supplicant



  • sudo nano명령어를 사용하여 wpa_supplicant.conf 내용을 다음과 같이 작성한다.

wpa_supplicant.conf 내용을 작성하는 과정

3. 이후 재부팅을 하고나면 다음과 같은 내용이 뜰 것이다.

이렇게 나오고 연결이 실패없이 완료되면 성공!

4. 성공! 이제 즐겁게 사용하시길-

3D 오브젝트의 Material 색을 변화시키고 싶을 때 아래 코드를 사용한다.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestRenderer : MonoBehaviour {

public Renderer m_Renderer;

float m_R = 0.4f;
float m_G = 0.5f;
float m_B = 0.3f;
float m_Alpha = 1f;

    void Start(){
        m_Renderer.material.color = new Color(m_R, m_G, m_B, m_Alpha);
    }

    void Update(){

        }
}




영상처리 프로젝트를 진행하기 시작하면서 단순 CPU만 사용하는 프로그래밍에 한계를 체감하기 시작했다.

기본적으로 1280x720 픽셀데이터를 다루는데만 한번 모든 픽셀을 훓는데만 921,600번의 연산이 필요하고 여기에 갖가지 영상처리 알고리즘이 들어가면 기하급수적인 연산이 걸린다. 각 연산은 단순 사칙연산인 경우가 많으나 연산이 너무 많으니 한번 프로그램을 돌리면 짧게는 몇분, 길게는 몇십분씩 연산이 돌아가니 점점 머리가 미쳐가기 시작했다.


이 많은 연산을 해결하기 위해 우리의 위대한 선조들은 이미 그래픽카드를 개발했고 이 그래픽카드의 GPU속 100코어가 넘는 코어들을 이용해 수많은 계산을 병렬처리로 연산하면서 심하게 오래걸리는 연산들을 단 몇초, 몇 밀리초 안에 해결하도록 솔루션을 내 놓았다.


최근 다양한 GPU Acceleration을 찾아보던 중 익숙한 C#으로 다룰 수 있는 OpenCL 라이브러리를 사용해 GPU Acceleration을 사용해보기로 했다.

먼저 라이브러리를 받아야 하므로 아래 링크에서 가입하거나 로그인해서 라이브러리를 받자.

https://www.codeproject.com/KB/dotnet/1116907/OpenCLLib.zip


비주얼 스튜디오에 DLL 파일을 참조할 수 있는 사람들은 패스하시고 못하시는 분은 아래글을 따라 참조한다.

1. '솔루션 탐색기'에서 '참조'를 오른쪽 클릭 후 '참조 추가'를 누른다.


2. 새로이 뜨는 '참조 관리자'창 우측 하단의 '찾아보기(B)'를 클릭 후 넣고자 하는 라이브러리.dll의 경로를 찾아 '추가'한다.(여기서는 OpenCLlib.dll과 Cloo.dll이다.)

'참조 관리자' 창 내에 추가된 라이브러리의 좌측 체크박스를 체크한다.

이후 '확인' 버튼을 클릭한다.


이렇게 추가한 후 코드 상단에

using OpenCL;

을 추가하여 사용한다.


코드 예제 (소수를 찾는 예제.)

using System; using System.Drawing; using Accord.Imaging.Filters; using Accord.DataSets; public class Program { public static void Main() { int[] Primes = Enumerable.Range(2, 1000000).ToArray(); //2부터 1,000,000까지의 배열 생성 EasyCL cl = new EasyCL(); // EasyCL 초기화         blur.Accelerator = AcceleratorDevice.GPU; // GPU Acceleration Device 설정

cl.LoadKernel(IsPrime); // IsPrime을 커널로 로드

cl.Invoke("GetIfPrime", 0, Primes.Length, Primes); // GetIfPrime을 인코딩하고 0에서 Prime 길이만큼 변수 셋팅 후 Prime 대입

}


static string IsPrime

{

    get

{

return @" //인코딩 될 부분 kernel void GetIfPrime(global int* message) // 소수점 찾는 메서드 { int index = get_global_id(0); int upperl=(int)sqrt((float)message[index]); for(int i=2;i<=upperl;i++) { if(message[index]%i==0) { //printf("" %d / %d\n"",index,i ); message[index]=0; return; } } //printf("" % d"",index); }";

}

} }






Accord.NET framework은 171가지의 이미지 필터링을 제공하고 있으며 그 목록은 다음과 같다. 


ClassDescription
Public classAdaptiveSmoothing
Adaptive Smoothing - noise removal with edges preserving.
Public classAdd
Add fillter - add pixel values of two images.
Public classAdditiveNoise
Additive noise filter.
Public classApplyMask
Apply mask to the specified image.
Public classBackwardQuadrilateralTransformation
Performs backward quadrilateral transformation into an area in destination image.
Public classBaseFilter
Base class for filters, which produce new image of the same size as a result of image processing.
Public classBaseFilter2
Base class for filters, which operate with two images of the same size and format and produce new image as a result.
Public classBaseInPlaceFilter
Base class for filters, which may be applied directly to the source image.
Public classBaseInPlaceFilter2
Base class for filters, which operate with two images of the same size and format and may be applied directly to the source image.
Public classBaseInPlacePartialFilter
Base class for filters, which may be applied directly to the source image or its part.
Public classBaseResizeFilter
Base class for image resizing filters.
Public classBaseRotateFilter
Base class for image rotation filters.
Public classBaseTransformationFilter
Base class for filters, which may produce new image of different size as a result of image processing.
Public classBaseUsingCopyPartialFilter
Base class for filters, which require source image backup to make them applicable to source image (or its part) directly.
Public classBayerDithering
Ordered dithering using Bayer matrix.
Public classBayerFilter
Generic Bayer fileter image processing routine.
Public classBayerFilterOptimized
Optimized Bayer fileter image processing routine.
Public classBilateralSmoothing
Bilateral filter implementation - edge preserving smoothing and noise reduction that uses chromatic and spatial factors.
Public classCode exampleBinaryDilation3x3
Binary dilation operator from Mathematical Morphology with 3x3 structuring element.
Public classBinaryErosion3x3
Binary erosion operator from Mathematical Morphology with 3x3 structuring element.
Public classCode exampleBinaryWatershed
Watershed filter.
Public classCode exampleBlend
Linear Gradient Blending filter.
Public classBlobsFiltering
Blobs filtering by size.
Public classBlur
Blur filter.
Public classBottomHat
Bottop-hat operator from Mathematical Morphology.
Public classBradleyLocalThresholding
Adaptive thresholding using the internal image.
Public classBrightnessCorrection
Brightness adjusting in RGB color space.
Public classBurkesDithering
Dithering using Burkes error diffusion.
Public classCannyEdgeDetector
Canny edge detector.
Public classCanvasCrop
Fill areas outiside of specified region.
Public classCanvasFill
Fill areas iniside of the specified region.
Public classCanvasMove
Move canvas to the specified point.
Public classChannelFiltering
Channels filters.
Public classClosing
Closing operator from Mathematical Morphology.
Public classColorFiltering
Color filtering.
Public classColorRemapping
Color remapping.
Public classCombineChannel
Combine channel filter.
Public classCompassConvolution
Compass convolution filter.
Public classConcatenate
Concatenation filter.
Public classConnectedComponentsLabeling
Connected components labeling.
Public classConservativeSmoothing
Conservative smoothing.
Public classContrastCorrection
Contrast adjusting in RGB color space.
Public classContrastStretch
Contrast stretching filter.
Public classConvolution
Convolution filter.
Public classCornersMarker
Filter to mark (highlight) corners of objects.
Public classCrop
Crop an image.
Public classDifference
Difference filter - get the difference between overlay and source images.
Public classDifferenceEdgeDetector
Difference edge detector.
Public classCode exampleDifferenceOfGaussians
Difference of Gaussians filter.
Public classDilation
dilation operator from Mathematical Morphology.
Public classDilation3x3
dilation operator from Mathematical Morphology with 3x3 structuring element.
Public classCode exampleDistanceTransform
Distance transform filter.
Public classDivide
Divide filter - divide pixel values of two images.
Public classEdges
Simple edge detector.
Public classErosion
Erosion operator from Mathematical Morphology.
Public classErosion3x3
Erosion operator from Mathematical Morphology with 3x3 structuring element.
Public classErrorDiffusionDithering
Base class for error diffusion dithering.
Public classErrorDiffusionToAdjacentNeighbors
Base class for error diffusion dithering, where error is diffused to adjacent neighbor pixels.
Public classEuclideanColorFiltering
Euclidean color filtering.
Public classCode exampleExponential
Exponential filter.
Public classExtractBiggestBlob
Extract the biggest blob from image.
Public classExtractChannel
Extract RGB channel from image.
Public classExtractNormalizedRGBChannel
Extract normalized RGB channel from color image.
Public classFastBoxBlur
Fast Box Blur filter.
Public classFastGuidedFilter
Fast Guided Filter (non-commercial).
Public classCode exampleFastVariance
Fast Variance filter.
Public classFeaturesMarker
Filter to mark (highlight) feature points in a image.
Public classFillHoles
Fill holes in objects in binary image.
Public classFilterIterator
Filter iterator.
Public classFiltersSequence
Filters' collection to apply to an image in sequence.
Public classFlatFieldCorrection
Flat field correction filter.
Public classFloydSteinbergDithering
Dithering using Floyd-Steinberg error diffusion.
Public classCode exampleGaborFilter
Gabor filter.
Public classGammaCorrection
Gamma correction filter.
Public classGaussianBlur
Gaussian blur filter.
Public classGaussianSharpen
Gaussian sharpen filter.
Public classGrayscale
Base class for image grayscaling.
Public classGrayscale.CommonAlgorithms
Set of predefined common grayscaling algorithms, which have already initialized grayscaling coefficients.
Public classGrayscaleBT709Obsolete.
Grayscale image using BT709 algorithm.
Public classGrayscaleRMYObsolete.
Grayscale image using R-Y algorithm.
Public classGrayscaleToRGB
Convert grayscale image to RGB.
Public classGrayscaleYObsolete.
Grayscale image using Y algorithm.
Public classCode exampleGrayWorld
Gray World filter for color normalization.
Public classHighBoost
High boost filter.
Public classHistogramEqualization
Histogram equalization filter.
Public classHitAndMiss
Hit-And-Miss operator from Mathematical Morphology.
Public classHomogenityEdgeDetector
Homogenity edge detector.
Public classHorizontalRunLengthSmoothing
Horizontal run length smoothing algorithm.
Public classHSLFiltering
Color filtering in HSL color space.
Public classHSLLinear
Luminance and saturation linear correction.
Public classHueModifier
Hue modifier.
Public classImageWarp
Image warp effect filter.
Public classIntersect
Intersect filter - get MIN of pixels in two images.
Public classInvert
Invert image.
Public classIterativeThreshold
Iterative threshold search and binarization.
Public classJarvisJudiceNinkeDithering
Dithering using Jarvis, Judice and Ninke error diffusion.
Public classJitter
Jitter filter.
Public classCode exampleKirschEdgeDetector
Kirsch's Edge Detector
Public classCode exampleKuwahara
Kuwahara filter.
Public classLevelsLinear
Linear correction of RGB channels.
Public classLevelsLinear16bpp
Linear correction of RGB channels for images, which have 16 bpp planes (16 bit gray images or 48/64 bit colour images).
Public classLineMarker
Filter to mark (highlight) lines in a image.
Public classCode exampleLogarithm
Log filter.
Public classMaskedFilter
Apply filter according to the specified mask.
Public classMean
Mean filter.
Public classMedian
Median filter.
Public classMerge
Merge filter - get MAX of pixels in two images.
Public classMirror
Mirroring filter.
Public classMorph
Morph filter.
Public classMoveTowards
Move towards filter.
Public classMultiply
Multiply filter - multiply pixel values of two images.
Public classCode exampleNiblackThreshold
Niblack Threshold.
Public classOilPainting
Oil painting filter.
Public classOpening
Opening operator from Mathematical Morphology.
Public classOrderedDithering
Binarization with thresholds matrix.
Public classOtsuThreshold
Otsu thresholding.
Public classPairsMarker
Filter to mark (highlight) pairs of points in a image.
Public classPixellate
Pixellate filter.
Public classPointedColorFloodFill
Flood filling with specified color starting from specified point.
Public classPointedMeanFloodFill
Flood filling with mean color starting from specified point.
Public classCode examplePointsMarker
Filter to mark (highlight) points in a image.
Public classQuadrilateralTransformation
Performs quadrilateral transformation of an area in a given source image.
Public classQuadrilateralTransformationBilinearObsolete.
Performs quadrilateral transformation using bilinear algorithm for interpolation.
Public classQuadrilateralTransformationNearestNeighborObsolete.
Performs quadrilateral transformation using nearest neighbor algorithm for interpolation.
Public classRectanglesMarker
Filter to mark (highlight) rectangles in a image.
Public classRectification
Rectification filter for projective transformation.
Public classReplaceChannel
Replace RGB channel of color imgae.
Public classResizeBicubic
Resize image using bicubic interpolation algorithm.
Public classResizeBilinear
Resize image using bilinear interpolation algorithm.
Public classResizeNearestNeighbor
Resize image using nearest neighbor algorithm.
Public classRGChromacity
RG Chromaticity.
Public classCode exampleRobinsonEdgeDetector
Robinson's Edge Detector
Public classRotateBicubic
Rotate image using bicubic interpolation.
Public classRotateBilinear
Rotate image using bilinear interpolation.
Public classRotateChannels
Rotate RGB channels.
Public classRotateNearestNeighbor
Rotate image using nearest neighbor algorithm.
Public classSaltAndPepperNoise
Salt and pepper noise.
Public classSaturationCorrection
Saturation adjusting in HSL color space.
Public classCode exampleSauvolaThreshold
Sauvola Threshold.
Public classSepia
Sepia filter - old brown photo.
Public classSharpen
Sharpen filter
Public classShrink
Shrink an image by removing specified color from its boundaries.
Public classSierraDithering
Dithering using Sierra error diffusion.
Public classSimplePosterization
Simple posterization of an image.
Public classSimpleQuadrilateralTransformation
Performs quadrilateral transformation of an area in the source image.
Public classSimpleSkeletonization
Simple skeletonization filter.
Public classSISThreshold
Threshold using Simple Image Statistics (SIS).
Public classSobelEdgeDetector
Sobel edge detector.
Public classStereoAnaglyph
Stereo anaglyph filter.
Public classStuckiDithering
Dithering using Stucki error diffusion.
Public classSubtract
Subtract filter - subtract pixel values of two images.
Public classTexturedFilter
Textured filter - filter an image using texture.
Public classTexturedMerge
Merge two images using factors from texture.
Public classTexturer
Texturer filter.
Public classThreshold
Threshold binarization.
Public classThresholdedDifference
Calculate difference between two images and threshold it.
Public classThresholdedEuclideanDifference
Calculate Euclidean difference between two images and threshold it.
Public classThresholdWithCarry
Threshold binarization with error carry.
Public classTopHat
Top-hat operator from Mathematical Morphology.
Public classTransformFromPolar
Transform polar image into rectangle.
Public classTransformToPolar
Transform rectangle image into circle (to polar coordinates).
Public classCode exampleVariance
Variance filter.
Public classVerticalRunLengthSmoothing
Vertical run length smoothing algorithm.
Public classWaterWave
Simple water wave effect filter.
Public classCode exampleWaveletTransform
Wavelet transform filter.
Public classCode exampleWhitePatch
White Patch filter for color normalization.
Public classCode exampleWolfJolionThreshold
Wolf Jolion Threshold.
Public classYCbCrExtractChannel
Extract YCbCr channel from image.
Public classYCbCrFiltering
Color filtering in YCbCr color space.
Public classYCbCrLinear
Linear correction of YCbCr channels.
Public classYCbCrReplaceChannel
Replace channel of YCbCr color space.
Public classZhangSuenSkeletonization
Zhang-Suen skeletonization filter.


이 필터들은 .NET Standard 2.0  .NET Core 2.0 에 완벽하게 호환 제공되고 있다.

이 필터들을 사용하기 위해서는 단순히

using Accord.Imaging.Filters;

을 네임스페이스 위에 삽입하여 사용하면 된다.


예제코드(가우시안 블러 사용 예제)

using System;
using System.Drawing;

using Accord.Imaging.Filters;
using Accord.DataSets;

					
public class Program
{
    public static void Main()
    {
        TestImages t = new TestImages();
        Bitmap baboon = t.GetImage("baboon.bmp");
		
        // We can create a new Gaussian Blur:
        GaussianBlur blur = new GaussianBlur();
        
        // Now we can either apply it to the image, creating a
        // new resulting image to hold the output of the filter:
        Bitmap result = blur.Apply(baboon);
        
        // Or we can apply the operation in place,
        // overwriting the original image:
        blur.ApplyInPlace(baboon);
    }
}



+ Recent posts