Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Support for darknet.h #4553

Open
peterdn1 opened this issue Dec 20, 2019 · 3 comments
Open

Java Support for darknet.h #4553

peterdn1 opened this issue Dec 20, 2019 · 3 comments

Comments

@peterdn1
Copy link

I have created a java lib using jna, it was a bit painful to get working.

Any interest in adding java support in addition to the current python support?

package darknet;

import com.sun.jna.Library;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.FloatByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;

public interface DarknetLib extends Library, YoloV2_Lib {
// parser.c
network load_network(String configurationFilename, String weightsFilename, int clear, int batch);// # batch size = 1
network load_network(String cfg,String weights, int clear);
network load_network_custom(String cfg,String weights, int clear, int batch);
// box.h
void do_nms_sort(detection dets, int total, int classes, float thresh);
void do_nms_obj(detection dets, int total, int classes, float thresh);
void diounms_sort(detection dets, int total, int classes, float thresh, int nms_kind, float beta1);
// network.h
float network_predict(network net, FloatByReference input);
float network_predict_ptr(network net, FloatByReference input);
Pointer get_network_boxes(network net, int w, int h, float thresh, float hier,IntByReference map, int relative, IntByReference num, int letter);
void free_detections(Pointer dets, int n);
void fuse_conv_batchnorm(network net);
void calculate_binary_weights(network net);
String detection_to_json(detection dets, int nboxes, int classes,String[] names,long frame_id, String filename);
detection make_network_boxes(network net, float thresh, IntByReference num);
void reset_rnn(network net);
float network_predict_image(network net, image im);
float network_predict_image_letterbox(network net, image im);
float validate_detector_map(String datacfg,String cfgfile,String weightfile, float thresh_calc_avg_iou, float iou_thresh,int map_points, int letter_box, network existing_net);
void train_detector(String datacfg,String cfgfile, String weightfile, IntByReference gpus, int ngpus, int clear, int dont_show, int calc_map, int mjpeg_port, int show_imgs);
void test_detector(String datacfg,String cfgfile, String weightfile, String filename, float thresh, float hier_thresh, int dont_show, int ext_output, int save_labels, String outfile, int letter_box);
int network_width(network net);
int network_height(network net);
void optimize_picture(network net, image orig, int max_layer, float scale, float rate, float thresh, int norm);
// image.h
image resize_image(image im, int w, int h);
void copy_image_from_bytes(image im, Pointer pdata);
image letterbox_image(image im, int w, int h);
void rgbgr_image(image im);
image make_image(int w, int h, int c);
image load_image_color(String filename, int w, int h);
void free_image(image m);
// layer.h
void free_layer(layer lay);
// data.c
void free_data(data d);
void load_thread(Pointer ptr);
// dark_cuda.h
void cuda_pull_array(FloatByReference x_gpu, FloatByReference x, LongByReference n);
void cuda_pull_array_async(FloatByReference x_gpu, FloatByReference x, LongByReference n);
void cuda_set_device(int n);
void cuda_get_context();
// utils.h
void free_ptrs(PointerByReference ptrs, int n);
void top_k(FloatByReference a, int n, int k, IntByReference index);
// tree.h
tree read_tree(String filename);
// option_list.h
metadata get_metadata(String file);
// http_stream.h
void delete_json_sender();
void send_json_custom(byte[] send_buf, int port, int timeout);
double get_time_point();
void start_timer();
void stop_timer();
double get_time();
void stop_timer_and_show();
void stop_timer_and_show_name(String name);
void show_total_time();
// gemm.h
void init_cpu();
}

@AlexeyAB
Copy link
Owner

@peterdn1 Hi,

Yes. If you can add Java-wrapper + short-Java-example(1 file) it would be nice.

There is also C#-wrapper, but I do not follow its relevance to the Darknet-library.
It was done by @tinohager
https://github.com/AlexeyAB/darknet/blob/master/build/darknet/YoloWrapper.cs

@tinohager
Copy link

@AlexeyAB & @peterdn1 Hi

The project use the darknet library and is popular.
https://github.com/AlturosDestinations/Alturos.Yolo

@peterdn1
Copy link
Author

peterdn1 commented Dec 20, 2019

Added a short example App.java and some test cases as well AppTest.java.
#4560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants