コード例 #1
0
ファイル: two_layer.cpp プロジェクト: vivekn/nnet
void test_data() {
	ifstream fin("ctest.csv");
	ofstream fout("test-output");

	while(!fin.eof()) {
		vector<int> image(NUM_PIXELS, 0);

		bool flag = false;

		for(int i=0; i < NUM_PIXELS; i++) {
			fin >> image[i];
			if (fin.eof()) {
				flag = true;
				break;
			}
		}

		if (flag) break;


		vector<int> binaryImage = threshold(image);

		fout << classify_image(binaryImage) << endl;
		// cout << image[123] << " "<< classify_image(binaryImage) << endl;
	}
}
コード例 #2
0
static GstFlowReturn
kms_face_detector_transform_frame_ip (GstVideoFilter * filter,
                                      GstVideoFrame * frame)
{
    KmsFaceDetector *facedetector = KMS_FACE_DETECTOR (filter);
    GstMapInfo info;

    if ((facedetector->priv->haar_detector)
            && (facedetector->priv->pCascadeFace == NULL)) {
        return GST_FLOW_OK;
    }

    kms_face_detector_initialize_images (facedetector, frame);
    gst_buffer_map (frame->buffer, &info, GST_MAP_READ);

    facedetector->priv->cvImage->imageData = (char *) info.data;
    cvResize (facedetector->priv->cvImage, facedetector->priv->cvResizedImage,
              CV_INTER_LINEAR);

    g_mutex_lock (&facedetector->priv->mutex);

    if (facedetector->priv->qos_control) {
        facedetector->priv->throw_frames++;
        GST_DEBUG ("Filter is too slow. Frame dropped %d",
                   facedetector->priv->throw_frames);
        g_mutex_unlock (&facedetector->priv->mutex);
        goto send;
    }

    g_mutex_unlock (&facedetector->priv->mutex);

    cvClearSeq (facedetector->priv->pFaceRectSeq);
    cvClearMemStorage (facedetector->priv->pStorageFace);
    if (facedetector->priv->haar_detector) {
        facedetector->priv->pFaceRectSeq =
            cvHaarDetectObjects (facedetector->priv->cvResizedImage,
                                 facedetector->priv->pCascadeFace, facedetector->priv->pStorageFace, 1.2,
                                 3, CV_HAAR_DO_CANNY_PRUNING,
                                 cvSize (facedetector->priv->cvResizedImage->width / 20,
                                         facedetector->priv->cvResizedImage->height / 20),
                                 cvSize (facedetector->priv->cvResizedImage->width / 2,
                                         facedetector->priv->cvResizedImage->height / 2));

    } else {
        classify_image (facedetector->priv->cvResizedImage,
                        facedetector->priv->pFaceRectSeq);
    }

send:
    if (facedetector->priv->pFaceRectSeq->total != 0) {
        kms_face_detector_send_event (facedetector, frame);
    }

    gst_buffer_unmap (frame->buffer, &info);

    return GST_FLOW_OK;
}
コード例 #3
0
ファイル: two_layer.cpp プロジェクト: vivekn/nnet
void train_image(vector<int> &image, int label) {
	// Increment weights
	for(int i=0; i < NUM_PIXELS; i++)
		if (image[i] > 0)
			weights[i][label]++;

	int guess = classify_image(image);

	// Decrement weights (error correction)
	for(int i=0; i < NUM_PIXELS; i++)
		if (image[i] > 0)
			weights[i][guess]--;
}
コード例 #4
0
ファイル: fdspatch.c プロジェクト: vrai/fdspatch
int main ( int argc, char** argv )
{
    FILE* fh;
    byte_t* buf;
    size_t flen;
    class_t cls;
    flags_t flags;
    if ( get_options ( argc, argv, &flags ) )
        return 1;
    if ( ! ( buf = alloc_buffer ( ) ) )
        return 1;
    if ( ! ( fh = open_input_file ( argv [ argc - 1 ] ) ) )
        return 1;
    if ( ! ( flen = load_file ( buf, fh ) ) )
        return 1;
    if ( classify_image ( &cls, buf, flen ) )
        return 1;

    if ( flags.action == ACTION_CONVERT )
        return action_convert ( &cls, buf, flen, argv [ argc - 1 ] );
    else
        return action_print ( &cls );
}