C++的数组传递

C++的数组传递    

     C++的数组传递都是通过指针传递的,这样就使得具有使用一个地址.

例如:

int face_features(cv::Mat image,float *gallery_fea){
    cv::Mat img_gray;
    if (image.channels() != 1)
        cv::cvtColor(image, img_gray, cv::COLOR_BGR2GRAY);
    else
        img_gray = image;
    face_recognizer.ExtractFeatureWithCrop(gallery_img_data_color, gallery_points, gallery_fea);
    }
在face_features函数中,不必使用return语句将gallery_fea数组返回,因为它使用的是地址传递,而非数值传递.

 

    float face_feature[2048];//定义一个2048大小数组
    while(!file.atEnd()) {
        QByteArray line = file.readLine();
        QString str(line);
        str.chop(1);
        qDebug()<<lines<<str;
        image=cv::imread(str.toStdString());
        memset(face_feature,0,sizeof(face_feature));//数组初始化
        face_features(image,face_feature);//传递数组的首地址
        for (int i=0;i<2048;i++){
            ClusterCenters.at<float>(lines,i)=face_feature[i];
        }
        lines++;
     }



                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值