Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
Binary file modified src/.DS_Store
Binary file not shown.
Binary file modified src/edge_detection/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions src/edge_detection/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ LDLIBS = `pkg-config --libs sdl2 SDL2_image` -lm

all: detection

SRC = detection.c image.c hough.c
SRC = detection.c hough.c
DEPS = ${SRC:.c=.d}
OBJ = ${SRC:.c=.o}
EXE = ${SRC:.c=}

.PHONY: clean

detection: image.o detection.o hough.o
detection: detection.o hough.o

clean:
${RM} ${DEPS}
Expand Down
24 changes: 20 additions & 4 deletions src/edge_detection/detection.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@

#include <err.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "image.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "hough.h"


int original_image_width = 0;
int original_image_height = 0;

SDL_Surface* load_image(const char* path)
{
SDL_Surface* is = IMG_Load(path);
if (is == NULL)
errx(EXIT_FAILURE, "%s", SDL_GetError());

SDL_Surface* fs = SDL_ConvertSurfaceFormat(is, SDL_PIXELFORMAT_RGB888, 0);
if (fs == NULL)
errx(EXIT_FAILURE, "%s", SDL_GetError());

SDL_FreeSurface(is);
return fs;
}


void update_render_scale(SDL_Renderer* renderer, int new_width, int new_height)
{
float scale_x = (float)new_width / original_image_width;
Expand Down Expand Up @@ -395,7 +411,7 @@ int main(int argc, char **argv){
free(vertical);
}
struct Squares* sq = drawsquares( lines, num_lines,horizon, vertical);
struct Squares s = findbestsquare( surface, vertical, horizon, sq, num_lines/2 );
struct Squares s = findbestsquare( surface, vertical, horizon, num_lines/2 );


SDL_Texture* grayscale_texture =
Expand Down Expand Up @@ -441,7 +457,7 @@ int main(int argc, char **argv){
}

struct Squares* sq = drawsquares(lines, num_lines, horizon, vertical);
struct Squares s = findbestsquare( surface, vertical, horizon, sq, num_lines/2 );
struct Squares s = findbestsquare( surface, vertical, horizon, num_lines/2 );


SDL_Texture* grayscale_texture = SDL_CreateTextureFromSurface(renderer, surface);
Expand Down
Loading